% Copyright 2019 by Till Tantau
%
% This file may be distributed and/or modified
%
% 1. under the LaTeX Project Public License and/or
% 2. under the GNU Free Documentation License.
%
% See the file doc/generic/pgf/licenses/LICENSE for more details.


% \section{Axes}
\section{坐标轴}
\label{section-dv-axes}

% \subsection{Overview}
\subsection{概述}

% When a data point is visualized, the most obvious way of creating a visual representation of its many attributes is to vary \emph{where} the data point is shown. The data visualization system uses \emph{axes} to turn data point attributes into positions on a page. The simplest -- and most common -- use of axes is to vary the horizontal position of data points according to one attribute and to vary the vertical position according to another attribute. In contrast, in a polar plot one attribute dictates the distance of the data point from the origin and another attribute describes the angle. From the data visualization engine's point of view, in both cases two \emph{axes} are involved.

当数据点可视化时，创建其许多属性的可视化表示的最明显方法是改变数据点显示的\emph{位置}。数据可视化系统使用\emph{坐标轴}将数据点属性转换为页面上的位置。坐标轴最简单也是最常见的用法是根据一个属性改变数据点的水平位置，并根据另一个属性改变垂直位置。相反，在极坐标图中，一个属性指定数据点到原点的距离，另一个属性描述角度。从数据可视化引擎的角度来看，在这两种情况下都涉及到两个\emph{坐标轴}。

% In addition to specifying how the value of a certain attribute is converted into a displacement on the page, an axis is also typically (but not always) visualized (``drawn'') somewhere on the page. In this case, it is also customary to add a visual representation on this axis of which attribute values correspond to which positions on the page -- something commonly known as \emph{ticks}. Similar to ticks, \emph{grid lines} also indicate positions where a certain attribute has a certain value, but instead of just indicating a single position on an axis, a grid line goes through all points that share an attribute value.

除了指定如何将某个属性的值转换为页面上的位置之外，坐标轴通常（但不总是）在页面的某个地方可视化（``绘制''）。在这种情况下，通常还需要在这个坐标轴上添加一个可视化代表值，该坐标轴的属性值对应于页面上的哪些位置——通常称为\emph{刻度}。与刻度类似，\emph{网格线}也指示某个属性具有某个值的位置，但网格线不只是指示轴上的单个位置，而是贯穿共享某个属性值的所有点。

% In the following, in Section~\ref{section-dv-axes-main} we first have a look at how axes can be defined and configured. As you will see, a lot of powerful configurations are available, but you will rarely define and configure an axis from scratch. Rather, it is more common to use a preconfigured axis instead. Section~\ref{section-dv-axis-systems} introduces \emph{axis systems}, which are predefined bundles of axes. You can define your own axis systems, but, again, in most cases it will suffice to just use one of the many preconfigured axis systems and use a few options to configure it so that it fits your need. Section~\ref{section-dv-ticks-and-grids} explains how ticks and grid lines can be configured. Again, several layers of options allow you to configure the way ticks look and where they are placed in great detail.

在下面的第\ref{section-dv-axes-main}节中，我们首先了解如何定义和配置坐标轴。正如您将看到的，有许多功能强大的配置可用，但您很少会从头定义和配置轴。相反，使用预配置的坐标轴更常见。第\ref{section-dv-axis-systems}节介绍\emph{坐标轴系统}，它是预定义的坐标轴束。您可以定义自己的坐标轴系统，但是，同样，在大多数情况下，只需使用许多预配置的坐标轴系统中的一个，并使用一些选项来配置它，以满足您的需要。第\ref{section-dv-ticks-and-grids}节解释了如何配置刻度和网格线。同样，多个选项层允许您配置刻度的外观以及它们的详细位置。

% This section documents the standard axis systems that are always available. For polar axis systems, a special library needs to be loaded, which is documented in Section~\ref{section-dv-polar}.

本节介绍始终可用的标准轴系统。对于极轴系统，需要加载一个特殊的库，这将在第\ref{section-dv-polar}节进行介绍。


% \subsection{Basic Configuration of Axes}
\subsection{坐标轴的基本配置}
\label{section-dv-axes-main}

% Inside the data visualization system, an \emph{axis} is roughly a ``systematic, named way of mapping an attribute to a position on a page''. For instance, the classical ``$x$-axis'' is the ``systematic way of mapping the value of the |x| attribute of data points to a horizontal position on the page''. An axis is \emph{not} its visual representation (such as the horizontal line with the ticks drawn to represent the $x$-axis), but a visual representation can be created once an axis has been defined.

在数据可视化系统中，坐标轴大致是一种``将属性映射到页面上某个位置的系统化、命名方式''。例如，经典的``$x$坐标轴''是``将数据点的$x$属性值映射到页面上的水平位置的系统方法''。坐标轴不是它的可视表示（例如绘制了刻度来表示$x$轴的水平线），但是定义了坐标轴之后，就可以创建可视化表示。

% The transformation of an attribute value (such as the value |1000000000| for the |x| attribute) to a specific displacement of the corresponding data point on the page involves two steps:

将属性值（例如 $x$ 属性的值 |1000000000|）转换为页面上相应数据点的特定位移涉及两个步骤：
%
\begin{enumerate}
    % \item First, the range of possible values such as $[-5.6\cdot 10^{12},7.8\cdot 10^{12}]$ must be mapped to a ``reasonable'' interval such as $[0\mathrm{cm},5\mathrm{cm}]$ or $[0^\circ,180^\circ]$. \tikzname's drawing routines will only be able to cope with values from such a ``reasonable'' interval.
    \item 首先，$[-5.6\cdot 10^{12},7.8\cdot 10^{12}]$的可能值范围必须映射到一个``合理''的区间，如$[0\mathrm{cm},5\mathrm{cm}]$或$[0^\circ,180^\circ]$。\tikzname 的绘图例程将只能处理来自这样一个``合理''间隔的值。
    % \item Second, the values from the reasonable interval must be mapped to a transformation.
    \item 其次，合理间隔中的值必须映射到坐标变换系统。
\end{enumerate}
%
% The first step is always the same for all axes, while the second requires different strategies. For this reason, the command |new axis base| is used to create a ``basic'' axis that has a ``scaling mapper'', whose job it is to map the range of values of a specific attribute to a reasonable interval, but such a basic axis does not define an actual transformation object. For this second step, additional objects such as a |linear transformer| need to be created separately.
%
对于所有坐标轴，第一步总是相同的，而第二步需要不同的策略。出于这个原因，命令 |new axis base| 用于创建一个``基本''轴，有一个``扩展映射器''，其工作是将特定属性的值范围映射到合理的间隔，但这样的基本轴并没有定义实际的变换对象。对于第二步，需要单独创建其他对象，比如 |linear transformer|。


% \subsubsection{Usage}
\subsubsection{用法}

% To create an axis, the key |new axis base| is used first. Since this key does not create a transformation object, users typically do not use this key directly. Rather, it is used internally by other keys that create ``real'' axes. These keys are listed in Section~\ref{section-dv-reference-axis-types}.

要创建一个坐标轴，首先使用键 |new axis base|。由于此键不创建坐标变换对象，用户通常不会直接使用此键。相反，它被其他创建``真实''轴的键在内部使用。这些键列在第\ref{Section -dv-reference-axis-types}节中。

\begin{key}{/tikz/data visualization/new axis base=\meta{坐标轴名称}} % \begin{key}{/tikz/data visualization/new axis base=\meta{axis name}}
    % This key defines a new axis for the current data visualization called \meta{name}. This has two effects:

    此键为当前数据可视化定义了一个名为 \meta{坐标轴名称} 的新坐标轴。它有两个效果：
    %
    \begin{enumerate}
        % \item A so called \emph{scaling mapper} is created that will monitor a certain attribute, rescale it, and map it to another attribute. (This will be explained in detail in a moment.)
        \item 将创建一个所谓的\emph{缩放映射器}，它将监视某个属性，重新缩放它，并将其映射到另一个属性。（稍后将对此进行详细解释。）
        % \item The \meta{axis name} is made available as a key that can be used to configure the axis:
        \item \meta{坐标轴名称} 作为一个键可用，可用于配置坐标轴：
            %
            \begin{key}{/tikz/data visualization/\meta{坐标轴名称}=\meta{选项}} % \begin{key}{/tikz/data visualization/\meta{axis name}=\meta{options}}
                % This key becomes available once |new axis base=|meta{axis name} has been called. It will execute the \meta{options} with the path prefix |/tikz/data visualization/axis options|.

                一旦调用了 |new axis base=|\meta{坐标轴名称}，此键就可用了。它将使用路径前缀 |/tikz/data visualization/axis options| 执行 \meta{选项}。
                %
\begin{codeexample}[code only]
[new axis base=my axis,
 my axis={attribute=some attribute}]
\end{codeexample}
            \end{key}
        % \item The \meta{axis name} becomes part of the current set of axes. This set can be accessed through the following key:
        \item \meta{坐标轴名称} 成为当前轴集的一部分。此集合可通过以下键访问：
            %
            \begin{key}{/tikz/data visualization/all axes=\meta{选项}} % \begin{key}{/tikz/data visualization/all axes=\meta{options}}
                % This key passes the \meta{options} to all axes inside the current scope, just as if you had written \meta{some axis name}|=|\meta{options} for each \meta{some axis name} in the current scope, including the just-created name \meta{axis name}.

                此键将 \meta{选项} 传递给当前分组内的所有坐标轴，就像您为当前分组内的每个使用 \meta{坐标轴名称系列}|=|\meta{选项} 一样，包括刚刚创建的 \meta{坐标轴美年广场}。
            \end{key}
    \end{enumerate}
    %
    % There are many \meta{options} that can be passed to a newly created axis. They are explained in the rest of this section.
    %
    有许多 \meta{选项} 可以传递给新创建的坐标轴。本节的其余部分将对它们进行解释。
\end{key}

% Note the |new axis base| does \emph{not} cause attributes to be mapped to positions on a page. Rather, special keys like |new Cartesian axis| first use |new axis base| to create an axis and then create an internal object that performs a linear mapping of the attribute to positions along a vectors.

注意，|new axis base| 确实会将属性映射到页面上的位置。相反，像 |new Cartesian axis| 这样的特殊键首先使用 |new axis base| 来创建一个坐标轴，然后创建一个内部对象，该对象将属性沿向量的位置进行线性映射。


% \subsubsection{The Axis Attribute}
\subsubsection{坐标轴属性}
\label{section-dv-axis-attribute}

% The first main job of an axis is to map the different values of some attribute to a reasonable interval. To achieve this, the following options are important (recall that these options are passed to the key whose name is the name of the axis):

坐标轴的第一个主要任务是将某个属性的不同值映射到一个合理的间隔。要实现这一点，以下选项很重要（回想一下，这些选项将传递给名称为坐标轴名称的键）：

\begin{key}{/tikz/data visualization/axis options/attribute=\meta{属性}} % \begin{key}{/tikz/data visualization/axis options/attribute=\meta{attribute}}
    % Specifies that the axis is used to transform the data points according the different values of the key |/data point/|\meta{attribute}. For instance, when we create a classical two-dimensional Cartesian coordinate system, then there are two axes called |x axis| and |y axis| that monitor the values of the attributes |/data point/x| and |/data point/y|, respectively:

    指定坐标轴用于根据键 |/data point/|\meta{属性} 的不同值转换数据点坐标。例如，当我们创建一个经典的二维笛卡尔坐标系时，有两个名为 |x axis| 和 |y axis| 分别监视属性 |/data point/x| 和 |/data point/y| 的值：
    %
\begin{codeexample}[code only]
  [new axis base=x axis,
   new axis base=y axis,
   x axis={attribute=x},
   y axis={attribute=y}]
\end{codeexample}
    %
    % In another example, we also create an |x axis| and a |y axis|. However, this time, we want to plot the values of the |/data point/time| attribute on the $x$-axis and, say, the value of the |height| attribute on the $y$-axis:
    % 
    在另一个例子中，我们还创建了一个 |x axis| 和一个 |y axis| 。但是，这一次，我们要绘制$x$轴上的 |/data point/time| 属性的值，$y$轴上的 |height| 属性的值：
    %
\begin{codeexample}[code only]
  [new axis base=x axis,
   new axis base=y axis,
   x axis={attribute=time},
   y axis={attribute=height}]
\end{codeexample}
    %
    % During the data visualization, the \meta{attribute} will be ``monitored'' during the survey phase. This means that for each data point, the current value of |/data point/|\meta{attribute} is examined and the minimum value of all of these values as well as the maximum value is recorded internally. Note that this works even when very large numbers like |100000000000| are involved.
    %
    在数据可视化期间，\meta{属性} 将在调查阶段被``监视''。这意味着对于每个数据点，检查 |/data point/|\meta{属性} 的当前值，并在内部记录所有这些值的最小值和最大值。注意，即使涉及到非常大的数字，如 |100000000000|，这种方法也可以正常工作。

    % Here is a real-life example. The |scientific axes| create two axes, called |x axis| and |y axis|, respectively.

    这里有一个实际的例子。|scientific axes| 创造了两个轴，分别称为 |x axis| 和 |y axis|。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [scientific axes,
                          x axis={attribute=people, length=2.5cm, ticks=few},
                          y axis={attribute=year},
                          visualize as scatter]
  data {
    year, people
    1900, 100
    1910, 200
    1950, 200
    1960, 250
    2000, 150
  };
\end{codeexample}
    %
\end{key}


% \subsubsection{The Axis Attribute Range Interval}
\subsubsection{坐标轴属性的范围}

% Once an attribute has been specified for an axis, the data visualization engine will start monitoring this value. This means that before anything actual visualization is done, a ``survey phase'' is used to determine the range of values encountered for the attribute for all data points. This range of values results in what is called the \emph{attribute range interval}. Its minimum is the smallest value encountered in the data and its maximum is the largest value.

为坐标轴指定属性后，数据可视化引擎将开始监视此值。这意味着在进行任何实际可视化之前，将使用``调查阶段''来确定所有数据点的属性值范围。这个值范围产生了所谓的\emph{属性范围间隔}。其最小值是在数据中遇到的最小值，其最大值是遇到的最大值。

% Even though the attribute range interval is computed automatically and even though you typically do not need to worry about it, there are some situations where you may wish to set or enlarge the attribute range interval:

即使属性范围间隔是自动计算的，即使您通常不需要担心它，但在某些情况下，您可能希望扩大属性范围间隔：
%
\begin{itemize}
    % \item You may wish to start the interval with $0$, even though the range of values contains only positive values.
    \item 您可能希望坐标轴以 |0| 开始，即使值范围仅包含正值。
    % \item You may wish to slightly enlarge the interval so that, say, the maximum is some ``nice'' value like |100| or |60|.
    \item 您可能希望稍微放大间隔，这样，比如说，最大值是一些``不错''的值，比如 |100| 或 |60|。
\end{itemize}

%The following keys can be used to influence the size of the attribute range interval:

以下键会影响属性范围间隔的大小：
%
\begin{key}{/tikz/data visualization/axis options/include value=\meta{值列表}} % \begin{key}{/tikz/data visualization/axis options/include value=\meta{list of value}}
    % This key ``fakes'' data points for which the attribute's values are in the comma-separated \meta{list of values}. For instance, when you write |include value=0|, then the attribute range interval is guaranteed to contain |0| -- even if the actual data points are all positive or all negative.

    这个键``伪造''属性值位于逗号分隔的 \meta{值列表} 中的数据点。例如，当您使用 |include value=0| 时，就保证属性范围间隔包含 |0| —— 即使实际数据点都是正的或负的。
    
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes, all axes={length=3cm},
                          visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes, all axes={length=3cm},
                          visualize as line,
                          x axis={include value=20},
                          y axis={include value=0}]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/axis options/min value=\meta{值}} % \begin{key}{/tikz/data visualization/axis options/min value=\meta{value}}
    % This key allows you to simply set the minimum value, regardless of which values are present in the actual data. This key should be used with care: If there are data points for which the attribute's value is less than \meta{value}, they will still be depicted, but typically outside the normal visualization area. Usually, saying |include value=|\meta{value} will achieve the same as saying |min value=|\meta{value}, but with less danger of creating ill-formed visualizations.

    这个键允许您简单地设置最小值，而不管实际数据中有哪些值。使用此键时要小心：如果存在属性值小于 \meta{值} 的数据点，它们仍然会被描述，但通常在正常的可视化区域之外。通常，使用 |include value=|\meta{值} 会达到与使用 |min value=|\meta{值} 相同的效果，但是会减少创建不良格式可视化的危险。
\end{key}

\begin{key}{/tikz/data visualization/axis options/max value=\meta{值}} % \begin{key}{/tikz/data visualization/axis options/max value=\meta{value}}
    % Works like |min value|. Works like |min value|.

    工作方式类似于 |min value|。
\end{key}


% \subsubsection{Scaling: The General Mechanism}
\subsubsection{缩放：一般机制}

% The above key allows us specify which attribute should be ``monitored''. The next key is used to specify what should happen with the observed values.

上面的键允许我们指定哪个属性应该被``监控''。下一个键用于指定观察到的值应该发生什么。

\begin{key}{/tikz/data visualization/axis options/scaling=\meta{缩放比例说明}} % \begin{key}{/tikz/data visualization/axis options/scaling=\meta{scaling spec}}
    % The \meta{scaling spec} must have the following form:

    \meta{缩放比例说明} 必须具有以下形式：
    %
    \begin{quote}
        \meta{$s_1$}| at |\meta{$t_1$}| and |\meta{$s_2$}| at |\meta{$t_2$}
    \end{quote}
    %
    % This means that monitored values in the interval $[s_1,s_2]$ should be mapped to values the ``reasonable'' interval $[t_1,t_2]$, instead. For instance, we might write
    %
    这意味着区间 $[s_1,s_2]$ 中的监视值应该映射到``合理的''区间$[t_1,t_2]$。例如，我们可能会写
    %
\begin{codeexample}[code only]
[y axis = {scaling = 1900 at 0cm and 2000 at 5cm}]
\end{codeexample}
    %
    % in order to map dates between 1900 and 2000 to the dimension interval $[0\mathrm{cm},5\mathrm{cm}]$.
    %
    为了将1900到2000年之间的日期映射到尺寸间隔$[0\mathrm{cm},5\mathrm{cm}]$。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization
   [scientific axes,
    x axis={attribute=people, length=2.5cm, ticks=few},
    y axis={attribute=year, scaling=1900 at 0cm and 2000 at 5cm},
    visualize as scatter]
  data {
    year, people
    1900, 100
    1910, 200
    1950, 200
    1960, 250
    2000, 150
  };
\end{codeexample}
    %
    % So much for the basic idea. Let us now have a detailed look at what happens.
    %
    基本思想到此为止。现在让我们详细看看发生了什么。


    \medskip
    % \textbf{Number format and the min and max keywords.} The source values $s_1$ and $s_2$ are typically just numbers like |3.14| or |10000000000|. However, as described in Section~\ref{section-dv-expressions}, you can also specify expressions like |(pi/2)|, provided that (currently) you put them in parentheses.

    \textbf{数字格式和最小最大关键字。} 源值$s_1$和$s_2$通常只是像 |3.14| 或 |10000000000| 这样的数字。但是，正如第\ref{Section -dv-expressions}节所描述的，您也可以指定像 |(pi/2)| 这样的表达式，只要将它们放在括号中（就目前而言）。

    % Instead of a number, you may alternatively also use the two key words |min| and |max| for $s_1$ and/or $s_2$. In this case, |min| evaluates to the smallest value observed for the attribute in the data, symmetrically |max| evaluates to the largest values. For instance, in the above example with the |year| attribute ranging from |1900| to |2000|, the keyword |min| would stand for |1900| and |max| for |2000|. Similarly, for the |people| attribute |min| stands for |100| and |max| for |250|. Note that |min| and |max| can only be used for $s_1$ and $s_2$, not for $t_1$ and $t_2$.

    对于$s_1$和/或$s_2$，您也可以使用两个关键字 |min| 和 |max| 代替数字。在本例中，|min| 计算为数据中该属性观察到的最小值，而对应地 |max| 为最大值。例如，在上面的例子中，|year| 属性从 |1900| 到 |2000|，关键字 |min| 代表 |1900|，|max| 代表 |2000|。类似地，对于 |people| 属性 |min| 代表 |100| 而 |max| 代表 |250|。注意，|min| 和 |max| 只能用于$s_1$和$s_2$，不能用于$t_1$和$t_2$。

    % A typical use of the |min| and |max| keywords is to say

    最典型的 |min| 和 |max| 关键字的用法是使用
    %
\begin{codeexample}[code only]
scaling = min at 0cm and max at 5cm
\end{codeexample}
    %
    % to map the complete range of values into an interval of length of 5cm.
    %
    将值的整个范围映射到长度为5cm的间隔中。

    % The interval  $[s_1,s_2]$ need not contain all values that the \meta{attribute} may attain. It is permissible that values are less than $s_1$ or more than $s_2$.

    间隔$[s_1,s_2]$不必包含 \meta{属性} 可能获得的所有值。允许值小于$s_1$或大于$s_2$。


    \medskip
    % \textbf{Linear transformation of the attribute.} As indicated earlier, the main job of an axis is to map values from a ``large'' interval $[s_1,s_2]$ to a more reasonable interval $[t_1,t_2]$. Suppose that for the current data point the value of the key |/data point/|\meta{attribute} is the number $v$. In the simplest case, the following happens: A new value $v'$ is computed so that $v' = t_1$ when $v=s_1$ and $v'=t_2$ when $v=s_2$ and $v'$ is some value in between $t_1$ and $t_2$ then $v$ is some value in between $s_1$ and $s_2$. (Formally, in this basic case $v' = t_1 + (v-s_1)\frac{t_2-t_1}{s_2-s_1}$.)

    \textbf{属性的线性变换。} 如前所述，轴的主要任务是将值从``大''区间$[s_1,s_2]$的值映射到更合理的区间$[t_1,t_2]$。假设对于当前数据点，键 |/data point/|\meta{属性} 的值是数字$v$。在最简单的情况下，会发生以下情况：计算一个新值$v'$，使得当$v=s_1$时有$v'= t_1$，当$v=s_2$时有$v'=t_2$，当$v'$是$t_1$和$t_2$之间的某个值时，$v$是$s_1$和$s_2$之间的某个值。（形式上，在这种基本情况下，$v' = t_1 + (v-s_1)\frac{t_2-t_1}{s_2-s_1}$）。

    % Once $v'$ has been computed, it is stored in the key |/data point/|\meta{attribute}|/scaled|. Thus, the ``reasonable'' value $v'$ does not replace the value of the attribute, but it is placed in a different key. This means that both the original value and the more ``scaled'' values are available when the data point is visualized.

    一旦$v'$被计算出来，它就被存储在关键 |/data point/|\meta{属性}|/scaled| 中。因此，``合理的''值$v'$不会替换属性的值，但是它被放置在不同的键中。这意味着当数据点被可视化时，原始值和更多的``缩放''值都是可用的。

    % As an example, suppose you have written

    例如，假设您编写了
    %
\begin{codeexample}[code only]
[x axis = {attribute = x, scaling=1000 at 20 and 2000 at 30}]
\end{codeexample}
    %
    % Now suppose that |/data point/x| equals |1200| for a data point. Then the key |/data point/x/scaled| will be set to |22| when the data point is being visualized.
    %
    现在假设 |/data point/x| 等于 |1200|。当数据点被可视化时，键 |/data point/x/scaled| 将被设置为 |22|。

    \medskip
    % \textbf{Nonlinear transformations of the attribute.} By default, the transformation of $[s_1,s_2]$ to $[t_1,t_2]$ is the linear transformation described above. However, in some case you may be interested in a different kind of transformation: For example, in a logarithmic plot, values of an attribute may range between, say, |1| and |1000| and we want an axis of length |3cm|. So, we would write

    \textbf{属性的非线性转换。} 默认情况下，$[s_1,s_2]$到$[t_1,t_2]$的变换就是上面描述的线性变换。但是，在某些情况下，您可能对另一种不同类型的变换感兴趣：例如，在对数图中，属性的值可能在 |1| 和 |1000| 之间，并且我们希望轴线的长度为 |3cm|。所以，我们会编写
    %
\begin{codeexample}[code only]
[x axis = {attribute = x, scaling=1 at 0cm and 1000 at 3cm}]
\end{codeexample}
    %
    % Indeed, |1| will now be mapped to position |0cm| and |1000| will be mapped to position |3cm|. Now, the value |10| will be mapped to approximately |0.03cm| because it is (almost) at one percent between |1| and |1000|. However, in a logarithmic plot we actually want |10| to be mapped to the position |1cm| rather than |0.03cm| and we want |100| to be mapped to the position |2cm|. Such a mapping a \emph{nonlinear} mapping between the intervals.
    %
    事实上，|1| 现在将被映射到位置 |0cm| 而 |1000| 将被映射到位置 |3cm|。现在，值 |10| 将被映射到大约 |0.03cm|，因为它（几乎）是在 |1| 和 |1000| 之间的1\%。然而，在一个对数图中，我们实际上想要 |10| 被映射到位置 |1cm| 而不是 |0.03cm|，而 |100| 被映射到位置 |2cm|。这样的映射是区间之间的\emph{非线性}映射。

    % In order to achieve such a nonlinear mapping, the |function| key can be used, whose syntax is described in a moment. The effect of this key is to specify a function $f \colon \mathbb{R} \to \mathbb{R}$ like, say, the logarithm function. When such a function is specified, the mapping of $v$ to $v'$ is computed as follows:

    为了实现这样的非线性映射，可以使用 |function| 键，稍后将对其语法进行描述。此键的作用是指定一个函数$f \colon \mathbb{R} \to \mathbb{R}$，例如对数函数。指定这样一个函数后，$v$到$v'$的映射计算如下:
    %
    \begin{align*}
        v' = t_1 + (f(s_2) - f(v))\frac{t_2 - t_1}{f(s_2)-f(s_1)}.
    \end{align*}

    % The syntax of the |function| key is described next, but you typically will not call this key directly. Rather, you will use a key like |logarithmic| that installs appropriate code for the |function| key for you.

    下面将介绍 |function| 键的语法，但通常不会直接调用该键。相反，您将使用像 |logarithmic| 这中为 |function| 键配置了适当的代码的键。
    %
    \begin{key}{/tikz/data visualization/axis options/function=\meta{代码}} % \begin{key}{/tikz/data visualization/axis options/function=\meta{code}}
        % The \meta{code} should specify a function $f$ that is applied during the transformation of the interval $[s_1,s_2]$ to the interval $[t_1,t_2]$ in the following way: When the \meta{code} is called, the macro |\pgfvalue| will have been set to an internal representation of the to-be-transformed value~$v$. You can then call the commands of the math-micro-kernel of the data visualization system, see Section~\ref{section-dv-math-kernel}, to compute a new value. This new value must once more be stored in |\pgfvalue|.

        在区间$[s_1,s_2]$到区间$[t_1,t_2]$的变换过程中，\meta{代码} 应该指定一个函数$f$，该函数按如下方式应用：当调用 \meta{代码} 时，宏 |\pgfvalue| 将被设置为要变换的值$v$的内部表示。然后，您可以调用数据可视化系统的数学微内核的命令（参见第\ref{section-dv-math-kernel}节）来计算一个新值。这个新值必须再次存储在 |\pgfvalue| 中。

        % The most common use of this key is to say

        此键最常见的用法是使用
        %
\begin{codeexample}[code only]
some axis={function=\pgfdvmathln{\pgfvalue}{\pgfvalue}}
\end{codeexample}
        %
        % This specifies that the function $f$ is the logarithm function.
        %
        这指定函数$f$是对数函数。
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization
   [scientific axes,
    x axis={ticks={major={at={1,10,100,1000}}},
             scaling=1 at 0cm and 1000 at 3cm,
             function=\pgfdvmathln{\pgfvalue}{\pgfvalue}},
    visualize as scatter]
  data [format=named] {
    x={1,100,...,1000}, y={1,2,3}
  };
\end{codeexample}
        %
        % Another possibility might be to use the square-root function, instead:
        %
        另一种可能是使用平方根函数：
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization
   [scientific axes,
    x axis={ticks=few,
            scaling=1 at 0cm and 1000 at 3cm,
            function=\pgfdvmathunaryop{\pgfvalue}{sqrt}{\pgfvalue}},
    visualize as scatter]
  data [format=named] {
    x={0,100,...,1000}, y={1,2,3}
  };
\end{codeexample}
    \end{key}


    \medskip
    % \textbf{Default scaling.} When no scaling is specified, it may seem natural to use $[0,1]$ both as the source and the target interval. However, this would not work when the logarithm function is used as transformations: In this case the logarithm of zero would be computed, leading to an error. Indeed, for a logarithmic axis it is far more natural to use $[1,10]$ as the source interval and $[0,1]$ as the target interval.

    \textbf{默认缩放。} 当没有指定缩放时，使用$[0,1]$作为源和目标间隔似乎是很自然的。但是，当使用对数变换时，这将不起作用：在这种情况下，将计算0的对数，从而导致错误。实际上，对于对数轴，更自然的做法是使用$[1,10]$作为源间隔，使用$[0,1]$作为目标间隔。

    % For these reasons, the default value for the |scaling| that is used when no value is specified explicitly can be set using a special key:

    由于这些原因，当没有显式指定值时使用的 |scaling| 的默认值可以使用一个特殊键来设置：
    %
    \begin{key}{/tikz/data visualization/axis options/scaling/default=\meta{文本}} % \begin{key}{/tikz/data visualization/axis options/scaling/default=\meta{text}}
        % The \meta{text} is used as |scaling| whenever no other scaling is specified. This key is mainly used when a transformation function is set using |function|; normally, you will not use this key directly.

        当没有指定其他扩展时，\meta{文本} 被用作 |scaling|。该键主要用于使用 |function| 设置变换函数时；通常，您不会直接使用此键。
    \end{key}
\end{key}

% Most of the time, you will not use neither the |scaling| nor the |function| key directly, but rather you will use one of the following predefined styles documented in the following.

大多数情况下，您不会直接使用 |scaling| 或 |function| 键，而是使用以下文档中描述的下列预定义样式之一。


% \subsubsection{Scaling: Logarithmic Axes}
\subsubsection{缩放：对数坐标轴}

\begin{key}{/tikz/data visualization/axis options/logarithmic}
    % When this key is used with an axis, three things happen:

    当将此键与坐标轴一起使用时，会发生三件事：
    %
    \begin{enumerate}
        % \item The transformation |function| of the axis is setup to the logarithm.
        \item 轴的 |function| 变换被设置为对数。
        % \item The strategy for automatically generating ticks and grid lines is set to the |exponential strategy|, see Section~\ref{section-dv-exponential-strategy} for details.
        \item 自动生成刻度和网格线的策略被设置为 |exponential strategy|，详细信息请参见第\ref{section-dv-exponential-strategy}节。
        % \item The default scaling is setup sensibly.
        \item 默认的缩放设置是合理的。
    \end{enumerate}
    %
    % All told, to turn an axis into a logarithmic axis, you just need to add this option to the axis.
    %
    总而言之，要将轴转换为对数轴，您只需将此选项添加到坐标轴即可。
    %
\begin{codeexample}[
    width=8cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization [scientific axes,
                          x axis={logarithmic},
                          y axis={logarithmic},
                          visualize as line]
 data [format=function] {
   var x : interval [0.01:100];
   func y = \value x * \value x;
 };
\end{codeexample}
    %
    %Note that this will work with any axis, including, say, the degrees on a polar axis:
    % 
    请注意，这将适用于任何坐标轴，包括极轴上的角度：
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}]
\tikz \datavisualization
    [new polar axes,
     angle axis={logarithmic, scaling=1 at 0 and 90 at 90},
     radius axis={scaling=0 at 0cm and 100 at 3cm},
     visualize as scatter]
  data [format=named] {
    angle={1,10,...,90}, radius={1,10,...,100}
  };
\end{codeexample}
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.polar}}]
\tikz \datavisualization
    [new polar axes,
     angle axis={degrees},
     radius axis={logarithmic, scaling=1 at 0cm and 100 at 3cm},
     visualize as scatter]
  data [format=named] {
    angle={1,10,...,90}, radius={1,10,...,100}
  };
\end{codeexample}
    %
\end{key}


% \subsubsection{Scaling: Setting the Length or Unit Length}
\subsubsection{缩放：设置坐标轴的长度或单位长度}

\begin{key}{/tikz/data visualization/axis options/length=\meta{尺寸}} % \begin{key}{/tikz/data visualization/axis options/length=\meta{dimension}}
    % Sets |scaling| to |min at 0cm and max at |\meta{dimension}. The effect is that the range of all values of the axis's attribute will be mapped to an interval of exact length \meta{dimension}.

    将 |scaling| 设置为 |min at 0cm and max at |\meta{尺寸}。其效果是，坐标轴属性的所有值的范围将映射到精确长度为 \meta{尺寸} 的间隔。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [scientific axes,
                          x axis={length=3cm},
                          y axis={length=2cm},
                          all axes={ticks=few},
                          visualize as line]
    data {
      x, y
      10, 10
      20, 20
      15, 30
      13, 20
    };
\end{codeexample}
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [scientific axes,
                          x axis={length=3cm},
                          y axis={length=4cm},
                          all axes={ticks=few},
                          visualize as line]
    data {
      x, y
      10, 10
      20, 20
      15, 30
      13, 20
    };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/axis options/unit length=\meta{尺寸}\opt{| per |\meta{数字}| units|}} % \begin{key}{/tikz/data visualization/axis options/unit length=\meta{dimension}\opt{| per |\meta{number}| units|}}
    % Sets |scaling| to |0 at 0cm and 1 at |\meta{dimension}. In other words, this key allows you to specify how long a single unit should be. This key is particularly useful when you wish to ensure that the same scaling is used across multiple axes or pictures.

    将 |scaling| 设置为 |0 at 0cm and 1 at |\meta{尺寸}。换句话说，这个键允许你指定一个单元应该有多长。当您希望确保在多个轴或图片上使用相同的缩放比例时，此键特别有用。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [scientific axes,
                          all axes={ticks=few, unit length=1mm},
                          visualize as line]
    data {
      x, y
      10, 10
      40, 20
      15, 30
      13, 20
    };
\end{codeexample}
    %
    % The optional |per |\meta{number}| units| allows you to apply more drastic scaling. Suppose that you want to plot a graph where one billion corresponds to one centimeter. Then the unit length would be need to be set to a hundredth of a nanometer -- much too small for \TeX\ to handle as a dimension. In this case, you can write |unit length=1cm per 1000000000 units|:
    %
    可选的  |per |\meta{数字}| units| 允许您应用更剧烈的缩放。假设你想画一幅图十亿对应于一厘米。然后需要将单位长度设置为百分之一纳米——对于\TeX\ 来说这样的尺寸太小了。在这种情况下，您可以使用 |unit length=1cm per 1000000000 units|：
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization
  [scientific axes,
   x axis={unit length=1mm per 1000000000 units, ticks=few},
   visualize as line]
 data {
   x, y
   10000000000, 10
   40000000000, 20
   15000000000, 30
   13000000000, 20
 };
\end{codeexample}
    %
\end{key}
%
\begin{key}{/tikz/data visualization/axis options/power unit length=\meta{尺寸}} % \begin{key}{/tikz/data visualization/axis options/power unit length=\meta{dimension}}
    % This key is used in conjunction with the |logarithmic| setting. It cases the |scaling| to be set to |1 at 0cm and 10 at |\meta{dimension}. This causes a ``power unit'', that is, one power of ten in a logarithmic plot, to get a length of \meta{dimension}. Again, this key is useful for ensuring that the same scaling is used across multiple axes or pictures.

    此键与 |logarithmic| 设置一起使用。它将 |scaling| 设置为 |1 at 0cm and 10 at |\meta{尺寸}。这将导致一个``幂单元''，即对数图中10的1次幂，从而得到一个 \meta{尺寸} 的长度。同样，这个键对于确保在多个轴或图片上使用相同的缩放比例非常有用。
    %
\begin{codeexample}[width=8cm,preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization
  [scientific axes,
   y axis={logarithmic, power unit length=1mm, grid},
   visualize as line]
 data {
   x, y
   0, 0.0000000001
   1, 1
   2, 100000
   3, 100000000000
   4, 10000000000000000000000000000000
   5, 500000000
   6, 5000000000000000000
 };
\end{codeexample}
    %
\end{key}


% \subsubsection{Axis Label}
\subsubsection{坐标轴标签}

% An axis can have a \emph{label}, which is a textual representation of the attribute according to which the axis varies the position of the page. You can set the attribute using the following key:

坐标轴可以有一个\emph{标签}，它是属性的文本表示形式，坐标轴根据属性的标签改变其在页面的位置。 您可以使用以下键设置属性：

\begin{key}{/tikz/data visualization/axis options/label=\opt{|\char`\{[|\meta{选项}|]|}\meta{文本}\opt{|\char`\}|}
  (default \normalfont axis's label in math mode)%
}
% \begin{key}{/tikz/data visualization/axis options/label=\opt{|\char`\{[|\meta{options}|]|}\meta{text}\opt{|\char`\}|}
%     (default \normalfont axis's label in math mode)%
% }
    % This key sets the label of an axis to \meta{text}. This text will typically be placed inside a |node| and the \meta{options} can be used to further configure the way this node is rendered. The \meta{options} will be executed with the path prefix |/tikz/data visualization/|, so you need to say |node style| to configure the styling of a node, see Section~\ref{section-dv-style}.

    此键将坐标轴的标签设置为 \meta{文本}。此文本通常被放置在 |node| 中，\meta{选项} 可用于进一步配置此节点的呈现方式。\meta{选项} 将以路径前缀 |/tikz/data visualization/| 执行，因此您需要使用 |node style| 来配置节点的样式，请参阅第\ref{section-dv-style}节。
    
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [
    scientific axes,
    x axis = {label, length=2.5cm},
    y axis = {label={[node style={fill=blue!20}]{$x^2$}}},
    visualize as smooth line]
 data [format=function] {
   var x : interval [-3:5];
   func y = \value x * \value x;
 };
\end{codeexample}
    %
\end{key}

% Note that using the |label| key does not actually cause a node to be created, because it is somewhat unclear where the label should be placed. Instead, the |visualize label| key is used (typically internally by an axis system) to show the label at some sensible position. This key is documented in Section~\ref{section-dv-visualize-label}.

请注意，使用 |label| 键实际上并不会创建节点，因为尚不清楚应将标签放置在何处。 相反，|visualize label| 键被用来（通常在坐标轴系统内部）在某个合理的位置显示标签。 此键记录在第\ref{section-dv-visualize-label}节中。


% \subsubsection{Reference: Axis Types}
\subsubsection{参考：坐标轴类型}
\label{section-dv-reference-axis-types}

% As explained earlier, when you use |new axis base| to create a new axis, a powerful scaling and attribute mapping mechanism is installed, but no mapping of values to positions on the page is performed. For this, a \emph{transformation object} must be installed. The following keys take care of this for you. Note, however, that even these keys do not cause a visual representation of the axis to be added to the visualization -- this is the job of an axis system, see Section~\ref{section-dv-axis-systems}.

如前所述，在使用 |new axis base| 创建新坐标轴时，将配置强大的缩放和属性映射机制，但不会执行值到页面上位置的映射。为此，必须配置\emph{变换对象}。下面的键为您解决这个问题。但是请注意，即使是这些键也不会将轴的可视化表示添加到可视化图形中——这是坐标轴系统的工作，请参阅第\ref{section-dv-axis-systems}节。

\begin{key}{/tikz/data visualization/new Cartesian axis=\meta{坐标轴名称}} % \begin{key}{/tikz/data visualization/new Cartesian axis=\meta{name}}
    % This key creates a new ``Cartesian'' axis, named \meta{name}. For such an axis, the (scaled) values of the axis's attribute are transformed into a displacement on the page along a straight line. The following key is used to configure in which ``direction'' the axis points:

    此键创建一个新的``笛卡尔''轴，命名为 \meta{坐标轴名称}。对于这样的坐标轴，坐标轴属性的（缩放后的）值将沿着一条直线在页面上转换为位移。以下键用于配置坐标轴的``方向''所在位置：
    %
    \begin{key}{/tikz/data visualization/axis options/unit vector=\meta{坐标} (initially {(1pt,0pt)})} % \begin{key}{/tikz/data visualization/axis options/unit vector=\meta{coordinate} (initially {(1pt,0pt)})}
        % Recall that an axis takes the values of an attribute and rescales them so that they fit into a ``reasonable'' interval $[t_1,t_2]$. Suppose that $v'$ is the rescaled dimension in (\TeX) points. Then when the data point is visualized, the coordinate system will be shifted by $v'$ times the \meta{coordinate}.

        回想一下，轴获取属性的值并对其进行重新缩放以使其适合于一个``合理''区间$[t_1,t_2]$。假设$v'$是（\TeX）数据点中重新缩放的倍数。然后当数据点被可视化时，坐标系统将将移动 ``\meta{坐标} 的$v'$倍''。

        % As an example, suppose that you have said |scaling=0 and 10pt and 50 and 20pt|. Then when the underlying attribute has the value |25|, it will be mapped to a $v'$ of $15$ (because |25| lies in the middle of |0| and |50| and |15pt| lies in the middle of |10pt| and |20pt|). This, in turn, causes the data point to be displaced by $15$ times the \meta{coordinate}.

        例如，假设您使用 |scaling=0 and 10pt and 50 and 20pt|。然后，当底层属性的值是 |25| 时，它将被映射到$15$的$v'$倍（因为 |25| 位于 |0| 和 |50| 的中间，|15pt| 位于 |10pt| 和 |20pt| 的中间）。这进而导致数据点被替换为$15$乘以 \meta{坐标}。

        % The bottom line is that the \meta{coordinate} should usually denote a point that is at distance |1pt| from the origin and that points into the direction of the axis.

        底线是 \meta{坐标} 通常应该表示距离原点 |1pt| 的点，并且指向坐标轴的方向。
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\begin{tikzpicture}
  \draw [help lines] (0,0) grid (3,2);

  \datavisualization
    [new Cartesian axis=x axis, x axis={attribute=x},
     new Cartesian axis=y axis, y axis={attribute=y},
     x axis={unit vector=(0:1pt)},
     y axis={unit vector=(60:1pt)},
     visualize as scatter]
  data {
    x, y
    0, 0
    1, 0
    2, 0
    1, 1
    2, 1
    1, 1.5
    2, 1.5
  };
\end{tikzpicture}
\end{codeexample}
    \end{key}
\end{key}


% \subsection{Axis Systems}
\subsection{坐标轴系统}
\label{section-dv-axis-systems}

% An \emph{axis system} is, as the name suggests, a whole family of axes that act in concert. For example, in the ``standard'' axis system there is a horizontal axis called the $x$-axis that monitors the |x| attribute (by default, you can change this easily) and a vertical axis called the $y$-axis. Furthermore, a certain number of ticks are added and labels are placed at sensible positions.

顾名思义，\emph{坐标轴系统}是一组相互作用的坐标轴。例如，在``标准''坐标轴系统中，有一个称为$x$轴的水平轴监视$x$属性（默认情况下，您可以很容易地更改它）和一个称为$y$轴的垂直轴。此外，添加一定数量的刻度，并将标签放置在合理的位置。


% \subsubsection{Usage}
\subsubsection{用法}

% Using an axis system is usually pretty easy: You just specify a key like |scientific axes| and the necessary axes get initialized with sensible default values. You can then start to modify these default values, if necessary.

使用坐标轴系统通常非常简单：只需指定一个键，如 |scientific axes|，然后使用合理的缺省值初始化必要的坐标轴。进一步，如果有需要，可以修改这些默认值。

% First, you can (and should) set the attributes to which the difference axes refer. For instance, if the |time| attribute is plotted along the $x$-axis, you would write

首先，您可以（并且应该）设置不同的坐标轴所引用的属性。 例如，如果 |time| 属性沿$x$轴绘制，您将编写
%
\begin{codeexample}[code only]
x axis = {attribute = time}
\end{codeexample}

% Second, you may wish to modify the lengths of the axes. For this, you can use keys like |length| or further keys as described in the references later on.

其次，您可能希望修改坐标轴的长度。 为此，可以使用 |length| 之类的键。 或其他文献中所述的键。

% Third, you may often wish to modify how many ticks and grid lines are shown. By default, no grid lines are shown, but you can say the following in order to cause grid lines to be shown:

第三，您可能经常希望修改显示的刻度线和网格线的数量。 默认情况下，不显示网格线，但是您可以使用以下内容以显示网格线：
%
\begin{codeexample}[code only]
all axes={grid}
\end{codeexample}
%
% Naturally, instead of |all axes| you can also specify a single axis, causing only grid lines to be shown for this axis. In order to change the number of ticks that are shown, you can say
%
自然，与其使用 |all axes| 您还可以指定一个轴，从而仅显示该轴的网格线。 为了更改显示的刻度数量，您可以使用
%
\begin{codeexample}[code only]
all axes={ticks=few}
\end{codeexample}
%
% or also |many| instead of |few| or even |none|. Far more fine-grained control over the tick placement and rendering is possible, see Section~\ref{section-dv-ticks-and-grids} for details.
%
或者使用 |many| 代替 |few| 甚至是 |none|。可以对刻度的放置和渲染进行更精细的控制，详细使用请参见第\ref{section-dv-ticks-and-grids}节。

% Fourth, consider adding units (like ``cm'' for centimeters or ``$\mathrm{m}/\mathrm{s}^2$'' for acceleration) to your ticks:

第四，考虑添加单位（如``cm''表示厘米，``$\mathrm{m}/\mathrm{s}^2$表示加速度）：
%
\begin{codeexample}[code only]
x axis={ticks={tick unit=cm}}, y axis={ticks={tick unit=m/s^2}}
\end{codeexample}

% Finally, consider adding labels to your axes. For this, use the label option:

最后，考虑在坐标轴上添加标签。 为此，请使用标签选项：
%
\begin{codeexample}[code only]
x axes={time $t$ (ms)}, y axis={distance $d$ (mm)}
\end{codeexample}

% Here is an example that employs most of the above features:

这是一个使用上述大多数功能的示例：
%
\begin{codeexample}[width=8.5cm,preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
  scientific axes=clean,
  x axis={attribute=time, ticks={tick unit=ms},
    label={elapsed time}},
  y axis={attribute=v, ticks={tick unit=m/s},
    label={speed of disc}},
  all axes=grid,
  visualize as line]
data {
  time, v
  0, 0
  1, 0.001
  2, 0.002
  3, 0.004
  4, 0.0035
  5, 0.0085
  6, 0.0135
};
\end{codeexample}


% \subsubsection{Reference: Scientific Axis Systems}
\subsubsection{参考：科学坐标轴系统}

\begin{key}{/tikz/data visualization/scientific axes=\opt{\meta{选项}}} % \begin{key}{/tikz/data visualization/scientific axes=\opt{\meta{options}}}
    % This key installs a two-dimensional coordinate system based on the attributes |/data point/x| and |/data point/y|.

    这个键配置一个基于属性 |/data point/x| 和 |/data point/y| 的二维坐标系统。
    %
\begin{codeexample}[
    width=7cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\begin{tikzpicture}
  \datavisualization [scientific axes,
                      visualize as smooth line]
    data [format=function] {
      var x : interval [0:100];
      func y = sqrt(\value x);
    };
\end{tikzpicture}
\end{codeexample}

    % This axis system is usually a good choice to depict ``arbitrary two dimensional data''. Because the axes are automatically scaled, you do not need to worry about how large or small the values will be. The name |scientific axes| is intended to indicate that this axis system is often used in scientific publications.

    该轴系通常是描绘``任意二维数据''的不错选择。 由于坐标轴是自动缩放的，因此您无需担心值的大小。 名称 |scientific axes| 旨在表明该轴系经常在科学出版物中使用。

    % You can use the \meta{options} to fine tune the axis system. The \meta{options} will be executed with the following path prefix:

    您可以使用 \meta{选项} 来微调坐标轴系统。\meta{选项} 将在以下路径前缀下执行：
    %
\begin{codeexample}[code only]
/tikz/data visualization/scientific axes
\end{codeexample}
    %
    % All keys with this prefix can thus be passed as \meta{options}.
    % 
    因此，所有带有此前缀的键都可以作为 \meta{选项} 传递。

    % This axis system will always distort the relative magnitudes of the units on the two axis. If you wish the units on both axes to be equal, consider directly specifying the unit length ``by hand'':

    这个坐标轴系统总是会使两个轴上的单位的相对大小发生扭曲。如果你希望两个轴上的单位相等，可以考虑直接``手动''指定单位长度：
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [visualize as smooth line,
                      scientific axes,
                      all axes={unit length=1cm per 10 units, ticks={few}}]
    data [format=function] {
      var x : interval [0:100];
      func y = sqrt(\value x);
    };
\end{tikzpicture}
\end{codeexample}

    % The |scientific axes| have the following properties:

    |scientific axes| 具有以下特性：
    %
    \begin{itemize}
        % \item The |x|-values are surveyed and the $x$-axis is then scaled and shifted so  that it has the length specified by the following key.
        \item 调查 |x| 值，然后缩放和移动$x$轴，使其具有以下键指定的长度。
            %
            \begin{key}{/tikz/data visualization/scientific axes/width=\meta{尺寸} (initially 5cm)} % \begin{key}{/tikz/data visualization/scientific axes/width=\meta{dimension} (initially 5cm)}
            \end{key}
            %
            % The minimum value is at the left end of the axis and at the canvas origin. The maximum value is at the right end of the axis. 
            %
            最小值在坐标轴的左端或画布原点处。最大值在坐标轴的右端。
        % \item The |y|-values are surveyed and the $y$-axis is then scaled so that is has the length specified by the following key.
        \item 调查 |y| 值，然后缩放$y$轴，使其具有以下键指定的长度。
            %
            \begin{key}{/tikz/data visualization/scientific axes/height=\meta{尺寸}} % \begin{key}{/tikz/data visualization/scientific axes/height=\meta{dimension}}
                % By default, the |height| is the golden ratio times the |width|.

                默认情况下，|height| 为黄金分割比乘以 |width|。
            \end{key}
            %
            % The minimum value is at the bottom of the axis and at the canvas origin. The maximum value is at the top of the axis.
            %
            最小值位于坐标轴的底部或画布原点。 最大值在坐标轴的顶部。
        % \item Lines (forming a frame) are depicted at the minimum and maximum values of the axes in 50\% black.
        \item 在轴的最小值和最大值处使用50\%的黑色线条表示坐标轴（形成一个坐标轴框架）。
    \end{itemize}

    % The following keys are executed by default as options: |outer ticks| and |standard labels|.

    以下键在默认情况下作为选项执行：|outer ticks| 和 |standard labels|。

    % You can use the following style to overrule the defaults:

    您可以使用以下样式来覆盖默认值：

    \begin{stylekey}{/tikz/data visualization/every scientific axes}
    \end{stylekey}
\end{key}

% The keys described in the following can be used to fine-tune the way the scientific axis system is rendered.

以下描述的键可用于微调科学轴系统的渲染方式。

\begin{key}{/tikz/data visualization/scientific axes/outer ticks}
    % This causes the ticks to be drawn `` on the outside'' of the frame so that they interfere as little as possible with the data. It is the default.

    这使得刻度线被画在框架的``外部''，从而使它们对数据的干扰尽可能小。 这是默认值。
    %
\begin{codeexample}[
    width=7cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\begin{tikzpicture}
  \datavisualization [scientific axes=outer ticks,
                      visualize as smooth line]
    data [format=function] {
      var x : interval [-12:12];
      func y = \value x*\value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/scientific axes/inner ticks}
    % This axis system works like |scientific axes|, only the ticks are on the ``inside'' of the frame.

    该坐标轴系统的工作方式类似于 |scientific axes|，只是刻度线位于框架``内部''。
    %
\begin{codeexample}[
    width=7cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\begin{tikzpicture}
  \datavisualization [scientific axes=inner ticks,
                      visualize as smooth line]
    data [format=function] {
      var x : interval [-12:12];
      func y = \value x*\value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}

    % This axis system is also common in publications, but the ticks tend to interfere with marks if they are near to the border as can be seen in the following example:

    此坐标轴系统在出版物中也很常见，但是如果刻度线靠近边界，则刻度线往往会干扰标记，如以下示例所示：
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\begin{tikzpicture}
  \datavisualization [scientific axes={inner ticks, width=3.2cm},
                      style sheet=cross marks,
                      visualize as scatter/.list={a,b}]
    data [set=a] {
      x, y
      0, 0
      1, 1
      0.5, 0.5
      2, 1
    }
    data [set=b] {
      x, y
      0.05, 0
      1.5, 1
      0.5, 0.75
      2, 0.5
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/scientific axes/clean}
    % The axes and the ticks are completely removed from the actual data, making this axis system especially useful for scatter plots, but also for most other scientific plots.

    坐标轴和刻度线已从实际数据中完全删除，这使得该坐标轴系统尤其适用于散点图以及大多数其他科学图。
    %
\begin{codeexample}[
    width=7.5cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization [
  scientific axes=clean,
  visualize as smooth line]
data [format=function] {
  var x : interval [-12:12];
  func y = \value x*\value x*\value x;
};
\end{codeexample}

    The distance of the axes from the actual plot is given by the padding of the axes.
\end{key}

For all scientific axis systems, different label placement strategies can be specified. They are discussed in the following.

\begin{key}{/tikz/data visualization/scientific axes/standard labels}
    As the name suggests, this is the standard placement strategy. The label of the $x$-axis is placed below the center of the $x$-axis, the label of the $y$-axis is rotated by $90^\circ$ and placed left of the center of the $y$-axis.
    %
\begin{codeexample}[
    width=8cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization
 [scientific axes={clean, standard labels},
  visualize as smooth line,
  x axis={label=degree $d$,
    ticks={tick unit={}^\circ}},
  y axis={label=$\sin d$}]
data [format=function] {
  var x : interval [-10:10] samples 10;
  func y = sin(\value x);
};
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/scientific axes/upright labels}
    % Works like |scientific axes standard labels|, only the label of the $y$-axis is not rotated.

    工作方式类似于 |scientific axes standard labels|，只是$y$轴的标签不旋转。
    %
\begin{codeexample}[
    width=8cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization [
  scientific axes={clean, upright labels},
  visualize as smooth line,
  x axis={label=degree $d$,
    ticks={tick unit={}^\circ}},
  y axis={label=$\cos d$, include value=1,
    ticks={style={
        /pgf/number format/precision=4,
        /pgf/number format/fixed zerofill}}}]
data [format=function] {
  var x : interval [-10:10] samples 10;
  func y = cos(\value x);
};
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/scientific axes/end labels}
    % Places the labels at the end of the $x$- and the $y$-axis, similar to the axis labels of a school book axis system.

    将标签放置在$x$轴和$y$轴的末端，类似于教科书坐标轴系统的轴标签。
    %
\begin{codeexample}[
    width=8cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization [
  scientific axes={clean, end labels},
  visualize as smooth line,
  x axis={label=degree $d$,
    ticks={tick unit={}^\circ}},
  y axis={label=$\tan d$}]
data [format=function] {
  var x : interval [-80:80];
  func y = tan(\value x);
};
\end{codeexample}
    %
\end{key}


% \subsubsection{Reference: School Book Axis Systems}
\subsubsection{参考：教科书坐标轴系统}

\begin{key}{/tikz/data visualization/school book axes=\meta{选项}} % \begin{key}{/tikz/data visualization/school book axes=\meta{options}}
    % This axis system is intended to ``look like'' the coordinate systems often used in school books: The axes are drawn in such a way that they intersect to origin. Furthermore, no automatic scaling is done to ensure that the lengths of units are the same in all directions.

    该坐标轴系统旨在``看起来像''教科书中经常使用的坐标系：以与原点相交的方式绘制坐标轴。 此外，没有进行自动缩放以确保单位长度在所有方向上都相同。

    % This axis system must be used with care -- it is nearly always necessary to specify the desired unit length by hand using the option |unit length|. If the magnitudes of the units on the two axes differ, different unit lengths typically need to be specified for the different axes.

    必须谨慎使用该坐标轴系统——几乎总是需要使用选项 |unit length| 手动指定所需的单位长度。 如果两个轴上的单位大小不同，则通常需要为不同的轴指定不同的单位长度。

    % Finally, if the data is ``far removed'' from the origin, this axis system will also ``look bad''.

    最后，如果数据离原点``很远''，这个坐标轴系统也会``看起来很糟糕''。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [school book axes, visualize as smooth line]
    data [format=function] {
      var x : interval [-1.3:1.3];
      func y = \value x*\value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}

    % The stepping of the ticks is one unit by default. Using keys like |ticks=some| may help to give better steppings.

    刻度的步进默认是一个单位。使用像 |ticks=some| 的键可能有助于提供更好的步长。

    % The \meta{options} are executed with the key itself as path prefix. Thus, the following subkeys are permissible options:

    以键本身作为路径前缀执行 \meta{选项}。因此，以下子键是允许的选项：
    %
    \begin{key}{/tikz/data visualization/school book axes/unit=\meta{数值}} % \begin{key}{/tikz/data visualization/school book axes/unit=\meta{value}}
        Sets the scaling so that 1\,cm corresponds to \meta{value} units. At the same time, the stepping of the ticks will also be set to \meta{value}.

        设置比例缩放，使1\,cm对应于 \meta{数值} 个单位。同时，刻度的步进也将设置为 \meta{数值}。
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [school book axes={unit=10},
                      visualize as smooth line,
                      clean ticks,
                      x axis={label=$x$},
                      y axis={label=$f(x)$}]
    data [format=function] {
      var x : interval [-20:20];
      func y = \value x*\value x/10;
    };
\end{tikzpicture}
\end{codeexample}
    \end{key}

    \begin{key}{/tikz/data visualization/school book axes/standard labels}
        % This key makes the label of the $x$-axis appear at the right end of this axis and it makes the label of the $y$-axis appear at the top of the $y$-axis.

        此键使$x$轴的标签出现在该轴的右端，并使$y$轴的标签出现在$y$轴的顶部。

        % Currently, this is the only supported placement strategy for the school book axis system.

        目前，这是教科书坐标轴系统唯一受支持的放置策略。
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [school book axes={standard labels},
                      visualize as smooth line,
                      clean ticks,
                      x axis={label=$x$},
                      y axis={label=$f(x)$}]
    data [format=function] {
      var x : interval [-1:1];
      func y = \value x*\value x + 1;
    };
\end{tikzpicture}
\end{codeexample}
    \end{key}
\end{key}


% \subsubsection{Advanced Reference: Underlying Cartesian Axis Systems}
\subsubsection{进阶参考：直角坐标轴系统}

% The axis systems described in the following are typically not used directly by the user. The systems setup \emph{directions} for several axes in some sensible way, but they do not actually draw anything on these axes. For instance, the |xy Cartesian| creates two axes called |x axis| and |y axis| and makes the $x$-axis point right and the $y$-axis point up. In contrast, an axis system like |scientific axes| uses the axis system |xy Cartesian| internally and then proceeds to setup a lot of keys so that the axis lines are drawn, ticks and grid lines are drawn, and labels are placed at the correct positions.

用户通常不会直接使用下面描述的坐标系统。系统以某种合理的方式为几个轴设置 \emph{方向}，但是它们实际上并没有在这些轴上绘制任何东西。例如，|xy Cartesian| 创建了两个坐标轴 |x axis| 和 |y axis| 使$x$坐标轴向右，$y$坐标轴向上。相比之下，像 |scientific axes| 这样的轴系统内部使用轴系统 |xy Cartesian|，然后继续设置许多键，以便绘制轴线、刻度线和网格线，并将标签放置在正确的位置。

\begin{key}{/tikz/data visualization/xy Cartesian}
    % This axis system creates two axes called |x axis| and |y axis| that point right and up, respectively. By default, one unit is mapped to one cm.

    该坐标轴系统创建两个称为 |x axis| 和 |y axis| 的轴。分别指向右边和上面。 默认情况下，一个单位映射为一厘米。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [xy Cartesian, visualize as smooth line]
    data [format=function] {
      var x : interval [-1.25:1.25];
      func y = \value x*\value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}

    \begin{key}{/tikz/data visualization/xy axes=\meta{选项}} % \begin{key}{/tikz/data visualization/xy axes=\meta{options}}
        % This key applies the \meta{options} both to the |x axis| and the |y axis|.

        此键同时将 \meta{选项} 应用于 |x axis| 和 |y axis|。
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/xyz Cartesian cabinet}
    % This axis system works like |xy Cartesian|, only it \emph{additionally} creates an axis called |z axis| that points left and down. For this axis, one unit corresponds to $\frac{1}{2}\sin 45^\circ\mathrm{cm}$. This is also known as a cabinet projection.

    这个坐标轴系统像 |xy Cartesian| 一样工作，只是它创建了一个轴叫 |z axis|，指向左边和下面。对于该轴，一个单元对应$\frac{1}{2}\ sin45 ^\circ$厘米。这也被称为半斜投影。

    \begin{key}{/tikz/data visualization/xyz axes=\meta{选项}} % \begin{key}{/tikz/data visualization/xyz axes=\meta{options}}
      此键同时将 \meta{选项} 应用于 |x axis| 和 |y axis|。
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/uv Cartesian}
    % This axis system works like |xy Cartesian|, but it introduces two axes called |u axis| and |v axis| rather than the |x axis| and the |y axis|. The idea is that in addition to a ``major'' $xy$-coordinate system this is also a ``smaller'' or ``minor'' coordinate system in use for depicting, say, small vectors with respect to this second coordinate system.

    这个坐标轴系统像 |xy Cartesian| 一样工作，但是它引入了两个轴，|u axis| 和 |v axis|，而不是 |x axis| 和 |y axis|。其思想是，除了一个主要的坐标系，这也是一个较小的或较小的坐标系，用于描述相对于第二个坐标系的小向量。

    \begin{key}{/tikz/data visualization/uv axes=\meta{选项}} % \begin{key}{/tikz/data visualization/uv axes=\meta{options}}
        % Applies the \meta{options} to both the |u axis| and the |y axis|.

        此键同时将 \meta{选项} 应用于 |u axis| 和 |v axis|。
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/uvw Cartesian cabinet}
    % Like |xyz Cartesian cabinet|, but for the $uvw$-system.

    类似于 |xyz Cartesian cabinet|，但适用于$uvw$系统。

    \begin{key}{/tikz/data visualization/uvw axes=\meta{选项}} % \begin{key}{/tikz/data visualization/uvw axes=\meta{options}} 
      % Like |xyz axes|.

      类似于 |xyz axes|。
    \end{key}
\end{key}


% \subsection{Ticks and Grids}
\subsection{刻度与网格}
\label{section-dv-ticks-and-grids}

% \subsubsection{Concepts}
\subsubsection{概念}

% A \emph{tick} is a small visual indication on an axis of the value of the axis's attribute at the position where the tick is shown. A tick may be accompanied additionally by a textual representation, but it need not. A \emph{grid line} is similar to a tick, but it is not an indication on the axis, but rather a whole line that indicates all positions where the attribute has a certain value. Unlike ticks, grid lines (currently) are not accompanied by a textual representation.

\emph{刻度}是在坐标轴上显示轴属性值的一个小的可视化指示。刻度可以用一个附加文本框表示，但实际上不需要这样大费周章。\emph{网格线}与刻度类似，但它不是轴上的指示线，而是一整条线，指示属性具有某个值的所有位置。与刻度不同，（当前）网格线不需要用文本表示。

% Just as for axes, the data visualization system decouples the specification of which ticks are present \emph{in principle} from where they are visualized. In the following, I describe how you specify which ticks and grid lines you would like to be drawn and how they should look like (their styling). The axis system of your choice will then visualize the ticks at a sensible position for the chosen system. For details on how to change where whole axis is shown along with its ticks, see Section~\ref{section-dv-visualize-ticks}.

就像坐标轴一样，数据可视化系统将刻度表示的规范与它们被可视化的地方分离开来。在下面，我将描述如何指定您想要绘制的刻度线和网格线，以及它们应该是什么样子（它们的样式）。然后，您所选择的坐标轴系统将在所选系统的一个合理位置上可视化刻度。有关如何更改整个坐标轴及其刻度的显示位置的详细信息，请参阅第\ref{section-dv-visualalize-ticks}节。

% Specifying which ticks you are interested in is done as follows: First, you use |ticks| key (or, for specifying which grid lines should be present, the |grid| key). This key takes several possible options, described in detail in the following, which have different effects:

指定你所感兴趣的刻度的步骤如下：首先，使用 |ticks| 键（或者，若指定应显示哪些网格线，使用 |grid| 键）。 该键具有几个可能的选项，下面将对其进行详细描述，它们会产生不同的效果：
%
\begin{enumerate}
    % \item Keys like |step=10| or |minor steps between steps| cause a ``semi-automatic'' computation of possible steps. Here, you explicitly specify the stepping of steps, but the first stepping and their number are computed automatically according to the range of possible values for the attribute.
    \item 像 |step=10| 或 |minor steps between steps| 之类的键可能会导致步长的``半自动''计算。 在这里，您明确指定了步长，但是第一步会根据属性的可能范围自动计算。
    % \item Keys like |few|, |some|, or |many| can be passed to |ticks| in order to have \tikzname\ compute good tick positions automatically. This is usually what you want to happen, which is why most axis system will implicitly say |ticks={some}|.
    \item 为了使\tikzname\ 自动计算合适的刻度位置，可以将诸如 |few|，|some|，或者 |many| 的键传递给刻度。 通常这就是您想要发生的情况，这就是为什么大多数坐标轴系统会隐式使用 |ticks={some}| 的原因。
    % \item Keys like |at| or |also at| provide ``absolute control'' over which ticks or grid lines are shown. For these keys, you can not only specify at what value a tick should be shown, but also its styling and also whether it is a major, minor, or subminor tick or grid line.
    \item |at| 或 |also at| 之类的键提供对刻度线或网格线的``绝对控制''。 对于这些键，您不仅可以指定应显示刻度线的值，还可以指定其样式以及主要，次要或次次要刻度或网格线。
\end{enumerate}

% In the following, the main keys |ticks| and |grids| are documented first. Then the different kinds of ways of specifying where ticks or grid lines should be shown are explained.

在下面，首先记录主要的键 |ticks| 和 |grids|。然后解释了如何使用不同方式指定刻度或网格线应该显示在何处。


% \subsubsection{The Main Options: Tick and Grid}
\subsubsection{主要选项：刻度和网格}

\begin{key}{/tikz/data visualization/axis options/ticks=\meta{选项} (default some)} % \begin{key}{/tikz/data visualization/axis options/ticks=\meta{options} (default some)}
    % This key can be passed to an axis in order to configure which ticks are present for the axis. The possible \meta{options} include, for instance, keys like |step|, which is used to specify a stepping for the ticks, but also keys like |major| or |minor| for specifying the positions of major and minor ticks in detail. The list of possible options is described in the rest of this section.

    可以将此键传递给坐标轴，以便配置为坐标轴提供哪些刻度。可能的 \meta{选项} 包括，例如，像 |step| 这样的键，它用于指定刻度的步长，还包括像 |major| 或 |minor| 这样的键，用于详细指定主要和次要刻度线的位置。其它可能的选项列表将在本节的其余部分进行描述。

    % Note that the |ticks| option will only configure which ticks should be shown in principle. The actual rendering is done only when the |visualize ticks| key is used, documented in Section~\ref{section-dv-visualize-ticks}, which is typically done only internally by an axis system.

    注意，|ticks| 选项将只配置原则上应该显示的刻度。实际的呈现只有在使用 |visualize ticks| 键后才会完成，详细用法记录在第\ref{section-dv-visualize-ticks}节中，这通常是由坐标轴系统内部完成的。

    % The \meta{options} will be executed with the path prefix |/tikz/data visualization/|. When the |ticks| key is used multiple times for an axis, the \meta{options} accumulate.

    \meta{选项} 将以路径前缀 |/tikz/data visualization/| 执行。当对一个坐标轴多次使用 |ticks| 键时，\meta{选项} 会累积。
    %
\begin{codeexample}[width=6cm,preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
  scientific axes, visualize as line,
  x axis={ticks={step=24, minor steps between steps=3},
          label=hours}]
  data {
    x, y
    0, 0
    10, 0
    20, 0.5
    30, 0.75
    40, 0.7
    50, 0.6
    60, 0.5
    70, 0.45
    80, 0.47
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/axis options/grid=\meta{选项} (default at default ticks)} % \begin{key}{/tikz/data visualization/axis options/grid=\meta{options} (default at default ticks)}
    % This key is similar to |ticks|, only it is used to configure where grid lines should be shown rather than ticks. In particular, the options that can be passed to the |ticks| key can also be passed to the |grid| key. Just like |ticks|, the \meta{options} only specify which grid lines should be drawn in principle; it is the job of the |visualize grid| key to actually cause any grid lines to be shown.

    这个键类似于 |ticks|，只是它用于配置网格线应该显示在哪里，而不是刻度。特别是，可以传递给 |ticks| 键的选项也可以传递给 |grid| 键。就像 |ticks| 一样，\meta{选项} 只指定原则上应该绘制哪些网格线；|visualize ticks| 键的任务是实际显示所有网格线。

    % If you do not specify any \meta{options}, the default text |at default ticks| is used. This option causes grid lines to be drawn at all positions where ticks are shown by default. Since this usually exactly what you would like to happen, most of the time you just need to |all axes=grid| to cause a grid to be shown.

    如果没有指定任何 \meta{选项}，则将使用默认刻度 |at default ticks|。此选项使默认情况下在刻度的所有位置绘制网格线。因为这通常是您想要发生的，大多数情况下，您只需要使用 |all axes=grid|，以使网格显示。
\end{key}

\begin{key}{/tikz/data visualization/axis options/ticks and grid=\meta{选项}} % \begin{key}{/tikz/data visualization/axis options/ticks and grid=\meta{options}}
    % This key passes the \meta{options} to both the |ticks| key and also to the |grid| key. This is useful when you want to specify some special points explicitly where you wish a tick to be shown and also a grid line.

    此键将 \meta{选项} 同时传递给 |ticks| 键和 |grid| 键。当您想在希望在显示刻度线的地方明确指定一些特殊刻度以及网格线时，此选项很有用。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   visualize as smooth line,
   all axes= {grid, unit length=1.25cm},
   y axis={ ticks=few },
   x axis={ ticks=many, ticks and grid={ major also at={(pi/2) as $\frac{\pi}{2}$}}}]
  data [format=function] {
    var x : interval [-pi/2:3*pi] samples 50;
    func y = sin(\value x r);
  };
\end{codeexample}
    %
\end{key}


% \subsubsection{Semi-Automatic Computation of Tick and Grid Line Positions}
\subsubsection{刻度线和网格线位置的半自动计算}
\label{section-dv-concept-tick-placement-strategies}

% Consider the following problem: The data visualization engine determines that in a plot the $x$-values vary between $17.4$ and $34.5$. In this case, we certainly do not want, say, ten ticks at exactly ten evenly spaced positions starting with $17.4$ and ending with $34.5$, because this would yield ticks at positions like $32.6$. Ticks should be placed at ``nice'' positions like $20$, $25$, and $30$.

考虑以下问题：数据可视化引擎在绘图过程中，$x$的值在$17.4$和$34.5$之间变化。在本例中，我们当然不想要恰好以$17.4$开始、$34.5$结束的10个均匀间隔的位置上的10个刻度，因为这将产生像$32.6$这样的刻度。刻度应该放在一个``合理的''位置，比如$20$，$25$，$30$。

% Determining which positions are ``nice'' is somewhat difficult. In the above example, the positions $20$, $25$, and $30$ are certainly nice, but only three ticks may be a bit few of them. Better might be the tick positions $17.5$, $20$, $22.5$, through to $32.5$. However, users might prefer even numbers over fractions like $2.5$ as the stepping.

确定哪些职位是“``合理''的有点困难。在上面的例子中，$20$，$25$，$30$的位置当然是不错的，但是只有三个刻度似乎有点少。更合理的选择是$17.5$，$20$，$22.5$，一直到$32.5$。但是，用户可能更喜欢证书，而不是像$2.5$这样的分数来作为刻度。

% A \emph{tick placement strategy} is a method of automatically deciding which positions are \emph{good} for placing ticks. The data visualization engine comes with a number of predefined strategies, but you can also define new ones yourself. When the data visualization is requested to automatically determine ``good'' positions for the placement of ticks on an axis, it uses one of several possible \emph{basic strategies}. These strategies differ dramatically in which tick positions they will choose: For a range of values between $5$ and $1000$, a |linear steps| strategy might place ticks at positions $100$, $200$, through to $1000$, while an |exponential steps| strategy would prefer the tick positions $10$, $100$ and $1000$. The exact number and values of the tick positions chosen by either strategy can be fine-tuned using additional options like |step| or |about|.

\emph{刻度放置策略}是一种自动决定哪些位置适合放置刻度的方法。数据可视化引擎提供了许多预定义的策略，但是您也可以自己定义新的策略。当要求数据可视化自动确定轴上刻度的``合理''位置时，它使用几种可能的\emph{基本策略}之一。对于$5$到$1000$的范围内，|linear steps| 策略可能会在$100$、$200$到4的位置设置刻度，而|指数步骤|策略更喜欢在$100$、$200$直到$1000$的位置设置刻度点。每一种策略所选择的刻度点位置的确切数量和值都可以使用额外的选项进行微调，如 |step| 或 |about|。

% Here is an example of the different stepping chosen when one varies the tick placement strategy:

这是一个示例，它改变了刻度线放置策略时选择的不同步长：
%
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [scientific axes, visualize as smooth line]
    data [format=function] {
      var x : interval [1:11];
      func y = \value x*\value x;
    };
\end{tikzpicture}
\qquad
\begin{tikzpicture}
  \datavisualization [scientific axes, visualize as smooth line,
    y axis={exponential steps},
    x axis={ticks={quarter about strategy}},
  ]
    data [format=function] {
      var x : interval [1:11];
      func y = \value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}

% Two strategies are always available: |linear steps|, which yields (semi)automatic ticks are evenly spaced positions, and |exponential steps|, which yields (semi)automatic steps at positions at exponentially increasing positions -- which is exactly what is needed for logarithmic plots. These strategies are details in Section~\ref{section-dv-strategies}.

有两种策略总是可用的：|linear steps|，产生均匀间隔位置的（半）自动刻度；以及 |exponential steps|，在指数增加位置上的位置，产生（半）自动刻度，一般用于对数图。 这些策略在第\ref{section-dv-strategies}节中有详细介绍。

% The following options are used to configure tick placement strategies like |linear steps|. Unlike the basic choice of a placement strategy, which is an axis option, the following should be passed to the option |ticks| or |grid| only. So, you would write things like |x axis={ticks={step=2}}|, but |x axis={linear steps}|.

下面的选项用于配置刻度放置策略，如 |linear steps|。与放置策略的基本选择（坐标轴选项）不同，下面的选项应该仅传递给选项 |ticks| 或 |grid|。你可以使用 |x axis={ticks={step=2}}|，但不能使用 |x axis={linear steps}|。

\begin{key}{/tikz/data visualization/step=\meta{值} (initially 1)} % \begin{key}{/tikz/data visualization/step=\meta{value} (initially 1)}
    % The value of this key is used to determine the spacing of the major ticks. The key is used by the |linear steps| and |exponential steps| strategies, see the explanations in Section~\ref{section-dv-strategies} for details. Basically, all ticks are placed at all multiples of \meta{value} that lie in the attribute range interval.

    此键的值用于确定主刻度的间距。这个键被 |linear steps| 和 |exponential steps| 策略所使用，详见第\ref{section-dv-strategies}节的解释。基本上，所有刻度都被放置在位于属性范围间隔内的 \meta{值} 的所有整数倍数处。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [
    school book axes, visualize as smooth line,
    y axis={ticks={step=1.25}},
  ]
    data [format=function] {
      var x : interval [0:3];
      func y = \value x*\value x/2;
    };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/minor steps between steps=\meta{数量} (default 9)} % \begin{key}{/tikz/data visualization/minor steps between steps=\meta{number} (default 9)}
    % Specifies that between any two major steps (whose positions are specified by the |step| key), there should be \meta{number} many minor steps. Note that the default of |9| is exactly the right number so that each interval between two minor steps is exactly a tenth of the size of a major step. See also Section~\ref{section-dv-strategies} for further details.

    指定在任意两个主刻度之间（其位置由 |step| 键指定）应该有 \meta{数量} 个小刻度。注意，缺省值 |9| 恰好是一个合理的数字，因为每两个小刻度之间的间隔恰好是大刻度的十分之一。更多细节请参见第\ref{section-dv-strategies}节。
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\begin{tikzpicture}
  \datavisualization [school book axes, visualize as smooth line,
    x axis={ticks={minor steps between steps=3}},
    y axis={ticks={minor steps between steps}},
  ]
    data [format=function] {
      var x : interval [-1.5:1.5];
      func y = \value x*\value x;
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/phase=\meta{值} (initially 0)} % \begin{key}{/tikz/data visualization/phase=\meta{value} (initially 0)}
    % See Section~\ref{section-dv-strategies} for details on how the phase of steps influences the tick placement.

    请参见第\ref{section-dv-strategies}节了解刻度相位如何影响刻度位置的详细信息。
\end{key}


% \subsubsection{Automatic Computation of Tick and Grid Line Positions}
\subsubsection{自动计算刻度线和网格线的位置}

% The |step| option gives you ``total control'' over the stepping of ticks on an axis, but you often do not know the correct stepping in advance. In this case, you may prefer to have a good value for |step| being computed for you automatically.

|step| 选项为您提供了对轴上刻度步进的``完全控制''，但是您通常无法预先知道正确的步进值。在这种情况下，您可能希望自动计算 |step| 的良好值。

% Like the |step| key, these options are passed to the |ticks| option. So, for instance, you would write |x axis={ticks={about=4}}| to request about four ticks to be placed on the $x$-axis.

与 |step| 键一样，这些选项也被传递给 |ticks| 选项。因此，例如，您可以编写 |x axis={ticks={about=4}}| 来请求在$x$轴上放置大约4个刻度。

\begin{key}{/tikz/data visualization/about=\meta{数量}} % \begin{key}{/tikz/data visualization/about=\meta{number}}
    % This key asks the data visualization to place \emph{about} \meta{number} many ticks on an axis. It is not guaranteed that \emph{exactly} \meta{number} many ticks will be used, rather the actual number will be the closest number of ticks to \meta{number} so that their stepping is still ``good''. For instance, when you say |about=10|, it may happen that exactly |10|, but perhaps even |13| ticks are actually selected, provided that these numbers of ticks lead to good stepping values like |5| or |2.5| rather than numbers like |3.4| or |7|. The method that is used to determine which steppings a deemed to be ``good'' depends on the current tick placement strategy.

    此键要求数据可视化在坐标轴上`\emph{大致}放置 \meta{数量} 个刻度。这并不能保证系统 \emph{严格}放置 \meta{数量} 个刻度，实际的刻度数量将是接近于 \meta{数量} 的刻度数量，这样可以保证步长仍然是``好的''。例如，当你使用 |about=10|，它可能正好放置了 |10| 个刻度，但实际上也可能放置 |13| 个刻度，只要这些刻度的数量可以产生一个较好的步长，如 |5| 或 |2.5|，而不是像 |3.4| 或 |7| 这样的数字。确定哪些步长被认为是``好的''取决于当前的刻度放置策略。


    \medskip
    % \textbf{Linear steps.} Let us start with |linear steps|: First, the difference between the maximum value $v_{\max}$ and the minimum value $v_{\min}$ on the axis is computed; let us call it $r$ for ``range''. Then, $r$ is divided by \meta{number}, yielding a target stepping~$s$. If $s$ is a number like $1$ or $5$ or $10$, then this number could be used directly as the new value of |step|. However, $s$ will typically something strange like $0.023\,45$ or $345\,223.76$, so $s$ must be replaced by a better value like $0.02$ in the first case and perhaps $250\,000$ in the second case.

    \textbf{线性步长刻度放置策略。}让我们从 |linear steps| 开始：首先，计算坐标轴上的最大值$v_{\max}$和最小值$v_{\min}$之间的差值；我们称它为$r$的``范围''。然后，我么将$r$除以 \meta{数量}，得到目标步长$s$。如果$s$是像$1$，$5$或$10$这样的数字，那么这个数字可以直接用作 |step| 的新值。然而，$s$通常会是一些奇怪的数字，比如像$0.023\,45$ 或者$345\,223.76$这样的数字，所以$s$必须使用一个更好的数字，比如在第一种情况下使用$0.02$，在第二种情况下可能使用$250\,000$。

    % In order to determine which number is to be used, $s$ is rewritten in the form $m \cdot 10^k$ with $1 \le m < 10$ and $k \in \mathbb Z$. For instance, $0.023\,45$ would be rewritten as $2.345 \cdot 10^{-2}$ and $345\,223.76$ as $3.452\,2376 \cdot 10^5$. The next step is to replace the still not-so-good number $m$ like $2.345$ or $3.452\,237$ by a ``good'' value $m'$. For this, the current value of the |about strategy| is used:

    为了确定使用哪个数字，$s$被重写为$m \cdot 10^k$的形式，其中$1 \le m < 10$ 以及 $k \in \mathbb Z$。例如，$0.023\,45$将重写为$2.345 \cdot 10^{-2}$，$345\,223.76$将重写为$3.452\,2376 \cdot 10^5$。下一步是将仍然不太好的数字$m$，如$2.345$或$3.452\,237$，替换为``良好的''数字$m'$。为此，我们将使用 |about strategy| 键的当前值：
    %
    \begin{key}{/tikz/data visualization/about strategy=\meta{列表}} % \begin{key}{/tikz/data visualization/about strategy=\meta{list}}
        % The \meta{list} is a comma-separated sequence of pairs \meta{threshold}/\meta{value} like for instance |1.5/1.0| or |2.3/2.0|. When a good value $m'$ is sought for a given $m$, we iterate over the list and find the first pair \meta{threshold}/\meta{value} where \meta{threshold} exceeds~$m$. Then $m'$ is set to \meta{value}. For instance, if \meta{list} is |1.5/1.0,2.3/2.0,4/2.5,7/5,11/10|, which is the default, then for $m=3.141$ we would get $m'=2.5$ since $4 > 3.141$, but $2.3 \le 3.141$. For $m=6.3$ we would get $m'=5$.

        \meta{列表} 是一个逗号分隔的序列对 \meta{阀值}/\meta{值}，类似于 |1.5/1.0| 或 |2.3/2.0|。当需要为给定的$m$寻找一个好的值$m'$时，我们遍历列表并找到第一个序列对 \meta{阀值}/\meta{值}，其中的 \meta{阀值} 大于$m$。然后$m'$被设置为 \meta{值}。例如，如果 \meta{列表}是 |1.5/1.0,2.3/2.0,4/2.5,7/5,11/10|，这也是该键的默认值，如果$m=3.141$，我们将得到$m'=2.5$，因为$4 > 3.141$，但$2.3 \le 3.141$。如果$m=6.3$，那么我们将得到$m'=5$。

        
    \end{key}
    %
    % Once $m'$ has been determined, the stepping is set to $s' = m' \cdot 10^k$.
    %
    一旦确定了$m'$，步进就将设置为$s' = m' \cdot 10^k$。

    % Define an axis type
    \tikzdatavisualizationset{
      one dimensional axis/.style={
        new Cartesian axis=axis,
        axis={
          attribute=main,
          unit vector={(0pt,1pt)},
          visualize axis={style=->},
          visualize ticks={major={tick text at low},direction axis=perpendicular},
          length=3cm
        },
        new Cartesian axis=perpendicular,
        perpendicular={
          attribute=perp,
          unit vector={(1pt,0pt)},
          include value=0,
          include value=1
        }
      }
    }

    \def\showstrategy#1{
        % Show the effect for the different strategies
        \medskip
        \begin{tikzpicture}
          \foreach \max/\about [count=\c] in {10/5,20/5,30/5,40/5,50/5,60/5,70/5,80/5,90/5,100/5,100/3,100/10}
          {
            \begin{scope}[xshift=\c pt*30]
              \datavisualization [#1,
              one dimensional axis,
              axis={
                ticks={about=\about},
                include value=0,
                include value=\max
              }
              ];

              \node at (0,-5mm) [anchor=mid] {\texttt{\about}};
            \end{scope}
          }

          \node at (30pt,-5mm) [anchor=mid east] {\texttt{about=\ \ }};
      \end{tikzpicture}
    }

    % The net effect of all this is that for the default strategy the only valid stepping are the values $1$, $2$, $2.5$ and $5$ and every value obtainable by multiplying one of these values by a power of ten. The following example shows the effects of, first, setting |about=5| (corresponding to the |some| option) and then having axes where the minimum value is always |0| and where the maximum value ranges from |10| to |100| and, second, setting |about| to the values from |3| (corresponding to the |few| option) and to |10| (corresponding to the |many| option) while having the minimum at |0| and the maximum at |100|:

    所有这些的最终结果是，对于默认策略，唯一有效的步长只有$1$、$2$、$2.5$和$5$，以及将它们乘以10的乘方可以得到的那些值。下面的例子将显示这种刻度放置策略的效果，首先，设置 |about=5|（对应于 |some| 选项），我们得到的坐标轴的最小值将总是 |0|，最大值在 |10| 到 |100| 之间变化，第二，设置 |about| 键在 |3|（对应于 |few| 选项）到 |10|（对应于 |many| 选项）之间变化，我们得到的坐标轴的最小值为 |0|，最大值为 |100|：

    \showstrategy{standard about strategy}

    \medskip
    \textbf{Exponential steps.}
    For |exponential steps| the strategy for determining a good stepping value is similar to |linear steps|, but with the following differences:
    %
    \begin{itemize}
        \item Naturally, since the stepping value refers to the exponent, the whole computation of a good stepping value needs to be done ``in the exponent''. Mathematically spoken, instead of considering the difference $r = v_{\max} - v_{\min}$, we consider the difference $r = \log v_{\max} - \log v_{\min}$. With this difference, we still compute $s = r / \meta{number}$ and let $s = m \cdot 10^k$ with $1 \le m < 10$.
        \item It makes no longer sense to use values like $2.5$ for $m'$ since this would yield a fractional exponent. Indeed, the only sensible values for $m'$ seem to be $1$, $3$, $6$, and $10$. Because of this, the |about strategy| is ignored and one of these values or a multiple of one of them by a power of ten is used.
    \end{itemize}

    The following example shows the chosen steppings for a maximum varying from
    $10^1$ to $10^5$ and from $10^{10}$ to $10^{50}$ as well as for $10^{100}$
    for |about=3|:

    \medskip
    \begin{tikzpicture}
      \foreach \max [count=\c] in {1,...,5,10,20,...,50,100}
        {
          \begin{scope}[xshift=\c pt*40]
            \datavisualization [
            one dimensional axis,
            axis={
              logarithmic,
              ticks={about=3},
              include value=1,
              include value=1e\max
            }
            ];
          \end{scope}
        }
    \end{tikzpicture}


    \medskip
    \textbf{Alternative strategies.}

    In addition to the standard |about strategy|, there are some additional strategies that you might wish to use instead:

    \begin{key}{/tikz/data visualization/standard about strategy}
        Permissible values for $m'$ are: $1$, $2$, $2.5$, and~$5$. This strategy is the default strategy.
    \end{key}

    \begin{key}{/tikz/data visualization/euro about strategy}
        Permissible values for $m'$ are: $1$, $2$, and~$5$. These are the same values as for the Euro coins, hence the name.

        \showstrategy{euro about strategy}
    \end{key}

    \begin{key}{/tikz/data visualization/half about strategy}
        Permissible values for $m'$: $1$ and $5$. Use this strategy if only powers of $10$ or halves thereof seem logical.

        \showstrategy{half about strategy}
    \end{key}

    \begin{key}{/tikz/data visualization/decimal about strategy}
        The only permissible value for $m'$ is $1$. This is an even more radical version of the previous strategy.

        \showstrategy{decimal about strategy}
    \end{key}

    \begin{key}{/tikz/data visualization/quarter about strategy}
        Permissible values for $m'$ are: $1$, $2.5$, and $5$.

        \showstrategy{quarter about strategy}
    \end{key}

    \begin{key}{/tikz/data visualization/int about strategy}
        Permissible values for $m'$ are: $1$, $2$, $3$, $4$, and $5$.

        \showstrategy{int about strategy}
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/many}
    This is an abbreviation for |about=10|.
\end{key}

\begin{key}{/tikz/data visualization/some}
    This is an abbreviation for |about=5|.
\end{key}

\begin{key}{/tikz/data visualization/few}
    This is an abbreviation for |about=3|.
\end{key}

\begin{key}{/tikz/data visualization/none}
    Switches off the automatic step computation. Unless you use |step=| explicitly to set a stepping, no ticks will be (automatically) added.
\end{key}


\subsubsection{Manual Specification of Tick and Grid Line Positions}

The automatic computation of ticks and grid lines will usually do a good job, but not always. For instance, you might wish to have ticks exactly at, say, prime numbers or at Fibonacci numbers or you might wish to have an additional tick at $\pi$. In these cases you need more direct control over the specification of tick positions.

First, it is important to understand that the data visualization system differentiates between three kinds of ticks and grid lines: major, minor, and subminor. The major ticks are the most prominent ticks where, typically, a textual representation of the tick is shown; and the major grid lines are the thickest. The minor ticks are smaller, more numerous, and lie between major ticks. They are used, for instance, to indicate positions in the middle between major ticks or at all integer positions between major ticks. Finally, subminor ticks are even smaller than minor ticks and they lie between minor ticks.

Four keys are used to configure the different kinds:

\begin{key}{/tikz/data visualization/major=\meta{options}}
    The key can be passed as an option to the |ticks| key and also to the |grid| key, which in turn is passed as an option to an axis. The \meta{options} passed to |major| specify at which positions major ticks/grid lines should be shown (using the |at| option and |also at| option) and also any special styling. The different possible options are described later in this section.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [ school book axes, visualize as smooth line,
    x axis={ticks={major={at={1, 1.5, 2}}}}]
  data [format=function] {
    var x : interval [-1.25:2];
    func y = \value x * \value x / 2;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/minor=\meta{options}} Like |major|, only for minor ticks/grid lines.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [ school book axes, visualize as smooth line,
    x axis={grid={minor={at={1, 1.5, 2}}}}]
  data [format=function] {
    var x : interval [-1.25:2];
    func y = \value x * \value x / 2;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/subminor=\meta{options}}
    Like |major|, only for subminor ticks/grid lines.
\end{key}

\begin{key}{/tikz/data visualization/common=\meta{options}}
    This key allows you to specify \meta{options} that apply to |major|, |minor| and |subminor| alike. It does not make sense to use |common| to specify positions (since you typically do not want both a major and a minor tick at the same position), but it can be useful to configure, say, the size of all kinds of ticks:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [ school book axes, visualize as smooth line,
    x axis={ticks={minor steps between steps, common={low=0}}} ]
  data [format=function] {
    var x : interval [-1.25:2];
    func y = \value x * \value x / 2;
  };
\end{codeexample}
    %
\end{key}

The following keys can now be passed to the |major|, |minor|, and |subminor| keys to specify where ticks or grid lines should be shown:

\begin{key}{/tikz/data visualization/at=\meta{list}}
    Basically, the \meta{list} must be a list of values that is processed with the |\foreach| macro (thus, it can contain ellipses to specify ranges of value). Empty values are skipped.

    The effect of passing |at| to a |major|, |minor|, or |subminor| key is that ticks or grid lines on the axis will be placed exactly at the values in \meta{list}. Here is an example:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [ school book axes, visualize as smooth line,
    x axis={ticks={major={at={-1,0.5,(pi/2)}}}}]
  data [format=function] {
    var x : interval [-1.25:2];
    func y = \value x * \value x / 2;
  };
\end{codeexample}
    When this option is used, any previously specified tick positions are overwritten by the values in \meta{list}. Automatically computed ticks are also overwritten. Thus, this option gives you complete control over where ticks should be placed.

    Normally, the individual values inside the \meta{list} are just numbers that are specified in the same way as an attribute value. However, such a value may also contain the keyword |as|, which allows you so specify the styling of the tick in detail. Section~\ref{section-dv-ticks-styling} details how this works.

    It is often a bit cumbersome that one has to write things like
    %
\begin{codeexample}[code only]
some axis = {ticks = {major = {at = {...}}}}
\end{codeexample}
    %
    A slight simplification is given by the following keys, which can be passed directly to |ticks| and |grid|:
    %
    \begin{key}{/tikz/data visualization/major at=\meta{list}}
        A shorthand for |major={at={|\meta{list}|}}|.
    \end{key}
    %
    \begin{key}{/tikz/data visualization/minor at=\meta{list}}
        A shorthand for |major={at={|\meta{list}|}}|.
    \end{key}
    %
    \begin{key}{/tikz/data visualization/subminor at=\meta{list}}
        A shorthand for |major={at={|\meta{list}|}}|.
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/also at=\meta{list}}
    This key is similar to |at|, but it causes ticks or grid lines to be placed at the positions in the \meta{list} \emph{in addition} to the ticks that have already been specified either directly using |at| or indirectly using keys like |step| or |some|. The effect of multiple calls of this key accumulate. However, when |at| is used after an |also at| key, the |at| key completely resets the positions where ticks or grid lines are shown.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [ school book axes, visualize as smooth line,
    x axis={grid, ticks and grid={major={also at={0.5}}}}]
  data [format=function] {
    var x : interval [-1.25:2];
    func y = \value x * \value x / 2;
  };
\end{codeexample}
    %
    As for |at|, there are some shorthands available:
    %
    \begin{key}{/tikz/data visualization/major also at=\meta{list}}
        A shorthand for |major={also at={|\meta{list}|}}|.
    \end{key}
    %
    \begin{key}{/tikz/data visualization/minor also at=\meta{list}}
        A shorthand for |major={also at={|\meta{list}|}}|.
    \end{key}
    %
    \begin{key}{/tikz/data visualization/subminor also at=\meta{list}}
        A shorthand for |major={also at={|\meta{list}|}}|.
    \end{key}
\end{key}


\subsubsection{Styling Ticks and Grid Lines: Introduction}
\label{section-dv-ticks-styling}

When a tick, a tick label, or a grid line is visualized on the page, a whole regiment of styles influences the appearance. The reason for this large number of interdependent styles is the fact that we often wish to influence only a very certain part of how a tick is rendered while leaving the other aspects untouched: Sometimes we need to modify just the font of the tick label; sometimes we wish to change the length of the tick label and the tick label position at the same time; sometimes we wish to change the color of grid line, tick, and tick label; and sometimes we wish to generally change the thickness of all ticks.

Let us go over the different kinds of things that can be styled (grid lines, ticks, and tick labels) one by one and let us have a look at which styles are involved. We will start with the grid lines, since they turn out to be the most simple, but first let us have a look at the general |style| and |styling| mechanism that is used in many placed in the following:


\subsubsection{Styling Ticks and Grid Lines: The Style and Node Style Keys}
\label{section-dv-style}

All keys of the data visualization system have the path prefix |/tikz/data visualization|. This is not only true for the main keys like |scientific axes| or |visualize as line|, but also for keys that govern how ticks are visualized. In particular, a style like |every major grid| has the path prefix |/tikz/data visualization| and all keys stored in this style are also executed with this path prefix.

Normally, this does not cause any trouble since most of the keys and even styles used in a data visualization are intended to configure what is shown in the visualization. However, at some point, we may also with to specify options that no longer configure the visualization in general, but specify the appearance of a line or a node on the \tikzname\ layer.

Two keys are used to ``communicate'' with the \tikzname\ layer:

\begin{key}{/tikz/data visualization/style=\meta{\tikzname\ options}}
    This key takes options whose path prefix is |/tikz|, not |/tikz/data visualization|. These options will be \emph{appended} to a current list of such options (thus, multiple calls of this key accumulate). The resulting list of keys is not executed immediately, but it will be executed whenever the data visualization engine calls the \tikzname\ layer to draw something (this placed will be indicated in the following).
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   all axes={ticks={style=blue}, length=3cm},
   y axis={grid, grid={minor steps between steps, major={style=red}}},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/styling}
    Executing this key will cause all ``accumulated'' \tikzname\ options from previous calls to the key |/tikz/data visualization/style| to be executed. Thus, you use |style| to set \tikzname\ options, but you use |styling| to actually apply these options. Usually, you do not call this option directly since this application is only done deep inside the data visualization engine.
\end{key}

Similar to |style| (and |styling|) there also exist the |node style| (and
|node styling|) key that takes \tikzname\ options that apply to nodes only --
in addition to the usual |style|.

\begin{key}{/tikz/data visualization/node style=\meta{\tikzname\ options}}
    This key works like |style|, but it has an effect only on nodes that are created during a data visualization. This includes tick labels and axis labels:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   all axes={ticks={node style=red}, length=3cm},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
    Note that in the example the ticks themselves (the little thicker lines)
    are not red.
\end{key}

\begin{key}{/tikz/data visualization/node styling}
    Executing this key will cause all ``accumulated'' node stylings to be
    executed.
\end{key}


\subsubsection{Styling Ticks and Grid Lines: Styling Grid Lines}
\label{section-dv-styling-grid-lines}

When a grid line is visualized, see Section~\ref{section-dv-visualize-gridlines} for details on when this happens, the following styles are executed in the specified order.
%
\begin{enumerate}
    \item |grid layer|.
    \item |every grid|.
    \item |every major grid| or |every minor grid| or |every subminor grid|, depending on the kind of grid line.
    \item locally specified options for the individual grid line, see Section~\ref{section-dv-local-styles}.
    \item |styling|, see Section~\ref{section-dv-style}.
\end{enumerate}

All of these keys have the path prefix |/tikz/data visualization|. However, the options stored in the first style (|grid layer|) and also in the last (|styling|) are executed with the path prefix |/tikz| (see Section~\ref{section-dv-style}).

Let us now have a look at these keys in detail:

\begin{stylekey}{/tikz/data visualization/grid layer (initially on background layer)}
\label{section-dv-grid-layer}%
    This key is used to specified the \emph{layer} on which grid lines should be drawn (layers are explained in Section~\ref{section-tikz-backgrounds}). By default, all grid lines are placed on the |background| layer and thus behind the data visualization. This is a sensible strategy since it avoids obscuring the more important data with the far less important grid lines. However, you can change this style to ``get the grid lines to the front'':
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   all axes={
     length=3cm,
     grid,
     grid={minor steps between steps}
   },
   grid layer/.style=, % none, so on top of data (bad idea)
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
    When this style is executed, the keys stored in the style will be executed with the prefix |/tikz|. Normally, you should only set this style to be empty or to |on background layer|.
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every grid}
    This style provides overall configuration options for grid lines. By default, it is set to the following:
    %
\begin{codeexample}[code only]
low=min, high=max
\end{codeexample}
    %
    This causes grid lines to span all possible values when they are visualized, which is usually the desired behavior (the |low| and |high| keys are explained in Section~\ref{section-dv-visualize-ticks}. You can append the |style| key to this style to configure the overall appearance of grid lines. It should be noted that settings to |style| inside |every grid| will take precedence over ones in |every major grid| and |every minor grid|. In the following example we cause all grid lines to be dashed (which is not a good idea in general since it creates a distracting background pattern).
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   all axes={length=3cm, grid},
   every grid/.append style={style=densely dashed},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every major grid}
    This style configures the appearance of major grid lines. It does so by calling the |style| key to setup appropriate \tikzname\ options for visualizing major grid lines. The default definition of this style is:
    %
\begin{codeexample}[code only]
style = {help lines, thin, black!25}
\end{codeexample}
    %
    In the following example, we use thin major blue grid lines:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes,
   all axes={
     length=3cm,
     grid,
     grid={minor steps between steps}
   },
   every major grid/.style = {style={blue, thin}},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
    As can be seen, this is not exactly visually pleasing. The default settings for the grid lines should work in most situations; you may wish to increase the blackness level, however, when you experience trouble during printing or projecting graphics.
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every minor grid}
    Works like |every major grid|. The default is
    %
\begin{codeexample}[code only]
style = {help lines, black!25}
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every subminor grid}
    Works like |every major grid|. The default is
    %
\begin{codeexample}[code only]
style = {help lines, black!10}
\end{codeexample}
    %
\end{stylekey}


\subsubsection{Styling Ticks and Grid Lines: Styling Ticks and Tick Labels}
\label{section-dv-styling-ticks}

Styling ticks and tick labels is somewhat similar to styling grid lines. Let us start with the tick \emph{mark}, that is, the small line that represents the tick. When this mark is drawn, the following styles are applied:
%
\begin{enumerate}
    \item |every ticks|.
    \item |every major ticks| or |every minor ticks| or |every subminor ticks|, depending on the kind of ticks to be visualized.
    \item locally specified options for the individual tick, see Section~\ref{section-dv-local-styles}.
    \item |tick layer|
    \item |every odd tick| or |every even tick|, see Section~\ref{section-dv-stacking}.
    \item |draw|
    \item |styling|, see Section~\ref{section-dv-style}.
\end{enumerate}

For the tick label node (the node containing the textual representation of the attribute's value at the tick position), the following styles are applied:
%
\begin{enumerate}
    \item |every ticks|.
    \item |every major ticks| or |every minor ticks| or |every subminor ticks|, depending on the kind of ticks to be visualized.
    \item locally specified options for the individual tick, see Section~\ref{section-dv-local-styles}.
    \item |tick node layer|
    \item |every odd tick| or |every even tick|, see Section~\ref{section-dv-stacking}.
    \item |styling|, see Section~\ref{section-dv-style}.
    \item |node styling|, see Section~\ref{section-dv-style}.
\end{enumerate}

\begin{stylekey}{/tikz/data visualization/every ticks}
    This style allows you to configure the appearance of ticks using the |style| and |node style| key. Here is (roughly) the default definition of
    this style:
    %
\begin{codeexample}[code only]
node style={
  font=\footnotesize,
  inner sep=1pt,
  outer sep=.1666em,
  rounded corners=1.5pt
}
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every major ticks}
    The default is
    %
\begin{codeexample}[code only]
  style={line cap=round}, tick length=2pt
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every minor ticks}
    The default is
    %
\begin{codeexample}[code only]
  style={help lines,thin, line cap=round}, tick length=1.4pt
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/every subminor ticks}
    The default is
    %
\begin{codeexample}[code only]
  style={help lines, line cap=round}, tick length=0.8pt
\end{codeexample}
    %
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/tick layer (initially on background layer)}
    Like |grid layer|, this key specifies on which layer the ticks should be
    placed.
\end{stylekey}

\begin{stylekey}{/tikz/data visualization/tick node layer (initially \normalfont empty)}
    Like |tick layer|, but now for the nodes. By default, tick nodes are placed on the main layer and thus on top of the data in case that the tick nodes are inside the data.
\end{stylekey}


\subsubsection{Styling Ticks and Grid Lines: Exceptional Ticks}

You may sometimes wish to style a few ticks differently from the other ticks. For instance, in the axis system |school book axes| there should be a tick label at the |0| position only on one axis and then this label should be offset a bit. In many cases this is easy to achieve: When you add a tick ``by hand'' using the |at| or |also at| option, you can add any special options in square brackets.

However, in some situations the special tick position has been computed automatically for you, for instance by the |step| key or by saying |tick=some|. In this case, adding a tick mark with the desired options using |also at| would cause the tick mark with the correct options to be shown in addition to the tick mark with the wrong options. In cases like this one, the following option may be helpful:

\begin{key}{/tikz/data visualization/options at=\meta{value} |as [|\meta{options}|]|}
    This key causes the \meta{options} to be executed for any tick mark(s) at \meta{value} in addition to any options given already for this position:
    %
\begin{codeexample}[
    width=7cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization [
  scientific axes,
  visualize as smooth line,
  x axis={ticks={major={
    options at = 3    as [no tick text],
    also at    = (pi) as
      [{tick text padding=1ex}] $\pi$}}}]
data [format=function] {
  var x : interval[0:2*pi];
  func y = sin(\value x r);
};
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/no tick text at=\meta{value}}
    Shorthand for |options at=|\meta{value}| as [no tick text]|.
\end{key}


\subsubsection{Styling Ticks and Grid Lines: Styling and Typesetting a Value}
\label{section-dv-local-styles}
\label{section-dv-tick-labels}

The \todosp{why 2 labels?} |at| and |also at| key allow you to provide a comma-separated \meta{list} of \meta{value}s where ticks or grid lines should be placed. In the simplest case, the \meta{value} is simply a number. However, the general syntax allows three different kinds of \meta{value}s:
%
\begin{enumerate}
    \item \meta{value}
    \item \meta{value} |as| |[|\meta{local options}|]|
    \item \meta{value} |as| \opt{|[|\meta{local options}|]|} \meta{text}
\end{enumerate}

In the first case, the \meta{value} is just a number that is interpreted like any other attribute value.

In the second case, where the keyword |as| is present, followed by some option in square brackets, but nothing following the closing square bracket, when the tick or grid line at position \meta{value} is shown, the \meta{local options} are executed first. These can use the |style| key or the |node style| key to configure the appearance of this single tick or grid line. You can also use keys like |low| or |high| to influence how large the grid lines or the ticks are or keys like |tick text at low| to explicitly hide or show a tick label.

In the third case, which is only important for |ticks| and not for |grid|, the same happens as in the second case, but the text that is shown as tick label is \meta{text} rather than the automatically generated tick label. This automatic generation of tick labels is explained in the following.
%
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes=clean,
   x axis={length=2.5cm, ticks={major at={
         5,
         6 as [style=red],
         7 as [{style=blue, low=-1em}],
         8 as [style=green] $2^3$,
         10 as ten
       }}},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}

A value like ``2'' or ``17'' could just be used as \meta{text} to be displayed in the node of a tick label. However, things are more difficult when the to-be-shown value is $0.0000000015$, because we then would typically (but not always) prefer something like $1.5 \cdot 10^{-9}$ to be shown. Also, we might wish a unit to be added like $23\mathrm{m}/\mathrm{s}$. Finally, we might wish a number like $3.141$ to be replaced by $\pi$. For these reasons, the data visualization system does not simply put the to-be-shown value in a node as plain text. Instead, the number is passed to a \emph{typesetter} whose job it is to typeset this number nicely using \TeX's typesetting capabilities. The only exception is, as indicated above, the third syntax version of the |at| and |also at| keys, where \meta{text} is placed in the tick label's node, regardless of what the typesetting would usually do.

The text produced by the automatic typesetting is computed as follows:
%
\begin{enumerate}
    \item The current contents of the key |tick prefix| is put into the node.
    \item This is followed by a call of the key |tick typesetter| which gets the \meta{value} of the tick as its argument in scientific notation.
    \item This is followed by the contents of the key |tick suffix|.
\end{enumerate}

Let us have a look at these keys in detail:

\begin{key}{/tikz/data visualization/tick prefix=\meta{text} (initially \normalfont empty)}
    The \meta{text} will be put in front of every typeset tick:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes, all axes={ticks=few, length=2.5cm},
   x axis={ticks={tick prefix=$\langle$, tick suffix=$]$}},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/tick suffix=\meta{text} (initially \normalfont empty)}
    Works like |tick prefix|. This key is especially useful for adding units like ``cm'' or ``$\mathrm m/\mathrm s$'' to every tick label. For this reason, there is a (near) alias that is easier to memorize:
    %
    \begin{key}{/tikz/data visualization/tick unit=\meta{roman math text}}
        A shorthand for |tick suffix={$\,\rm|\meta{roman math text}|$}|:
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization
  [scientific axes, all axes={length=3cm},
   x axis={ticks={tick unit=s}},
   y axis={ticks={tick unit=m/s^2}},
   visualize as line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    \end{key}
\end{key}

\begin{key}{/tikz/data visualization/tick typesetter=\meta{value}}
    The key gets called for each number that should be typeset. The argument \meta{value} will be in scientific notation (like |1.0e1| for $10$). By default, this key applies |\pgfmathprintnumber| to its argument. This command is a powerful number printer whose configuration is documented in Section~\ref{pgfmath-numberprinting}.

    You are invited to code underlying this key so that a different typesetting mechanism is used. Here is a (not quite finished) example that shows how, say, numbers could be printed in terms of multiples of $\pi$:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\def\mytypesetter#1{%
  \pgfmathparse{#1/pi}%
  \pgfmathprintnumber{\pgfmathresult}$\pi$%
}
\tikz \datavisualization
  [school book axes, all axes={unit length=1.25cm},
   x axis={ticks={step=(0.5*pi), tick typesetter/.code=\mytypesetter{##1}}},
   y axis={include value={-1,1}},
   visualize as smooth line]
  data [format=function] {
    var x : interval [0.5:7];
    func y = sin(\value x r);
  };
\end{codeexample}
    %
\end{key}


\subsubsection{Stacked Ticks}
\label{section-dv-stacking}

Sometimes, the text of tick labels are so long or so numerous that the text of adjacent tick labels overlap (or have too little padding):
%
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
%
There are two ways to address this problem:
%
\begin{itemize}
    \item One can rotate the labels on horizontal axes:
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          x axis={ticks={node style={rotate=90, anchor=east}}},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
        %
        This is often a good solution, but may be hard to read. Also consider rotating labels only by $45^\circ$ or $30^\circ$.
    \item One can specify different shifts of the nodes for the different ticks, whereby the ticks text no longer overlap.
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          x axis={ticks={major at={0,4000,8000,
                                2000 as [node style={yshift=-1em}],
                                6000 as [node style={yshift=-1em}],
                                10000 as [node style={yshift=-1em}]}}},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
        %
        However, specifying shifts ``by hand'' in the above way is not always an option, especially when the tick positions should be computed automatically. Instead, the |stack| option can be used, which is much easier to use and gives better results:
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm}, x axis={ticks=stack},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
        %
\end{itemize}

The |stack| option is actually just a style that gives you access to the general even/odd mechanism for ticks with labels. Whenever a tick mark is created where a tick label is also to be drawn, two special things happen:
%
\begin{enumerate}
    \item For every odd tick mark, the |every odd tick| style is executed, for every even tick mark the |every even tick|. Here, ``odd'' and ``even'' are with respect to the order in which the ticks have been added to the list of |at| positions for each major, minor, or subminor tick list, not with respect to the order in which they will appear on the axis. Thus, when you write
        %
\begin{codeexample}[code only]
ticks={major at={1,2,3,4}, major at={0,-1,-2}, minor at={9,8,7}}
\end{codeexample}
        %
        then for |1|, |3|, |0|, and |-2| as well as |9| and |7| the key |every odd tick| will be executed, while |every even tick| will be executed for positions |2|, |4|, |-1|, and also |8|.
    \item When a tick node label is shown at the |low| position of the tick mark, the dimension stored in the key |tick text low even padding| is added to the |low| value. Provided that this padding is not zero (which is the default), the length of the even tick marks will be increased and the tick label node will be placed at a greater distance from the axis.

        Similar keys exist for padding ticks with labels at high positions and
        also at even positions.
\end{enumerate}

\begin{key}{/tikz/data visualization/tick text low even padding=\meta{dimension} (initially 0pt)}
    When a tick label is shown at the low position of an even tick, the \meta{distance} is added to the |low| value, see also Section~\ref{section-dv-visualize-ticks}.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          x axis={ticks={tick text low even padding=-1em}},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
    %
    Note that \meta{dimension} should usually be non-positive.
\end{key}

The following keys work similarly:
%
\begin{key}{/tikz/data visualization/tick text low odd padding=\meta{dimension} (initially 0pt)}
\end{key}
%
\begin{key}{/tikz/data visualization/tick text high even padding=\meta{dimension} (initially 0pt)}
\end{key}
%
\begin{key}{/tikz/data visualization/tick text high odd padding=\meta{dimension} (initially 0pt)}
\end{key}

\begin{key}{/tikz/data visualization/tick text odd padding=\meta{dimension}}
    A shorthand for setting |tick text odd low padding| and
    |tick text odd high padding| at the same time.
\end{key}

\begin{key}{/tikz/data visualization/tick text even padding=\meta{dimension}}
    A shorthand for setting |tick text even low padding| and
    |tick text even high padding| at the same time.
\end{key}

\begin{key}{/tikz/data visualization/tick text padding=\meta{dimension}}
    Sets all text paddings to \meta{dimension}.
\end{key}

\begin{key}{/tikz/data visualization/stack=\meta{dimension} (default 1em)}
    Shorthand for |tick text even padding=|\meta{dimension}.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          x axis={ticks={stack=1.5em}},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
    %
\end{key}

\begin{key}{/tikz/data visualization/stack'=\meta{dimension}}
    Shorthand for |tick text odd padding=|\meta{dimension}. The difference to
    |stack| is that the set of value that are ``lowered'' is exactly exchanged
    with the set of value ``lowered'' by |stack|.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes,
                          all axes={length=2.5cm},
                          x axis={ticks=stack'},
                          visualize as smooth line]
  data [format=function] {
    var y : interval[-100:100];
    func x = \value y*\value y;
  };
\end{codeexample}
    %
\end{key}

Note that the above keys have an effect on all tick labels of an axis, also on special ticks that you may have added using the |also at| key. When using the |stack| key, you should specify a |tick text padding| explicitly for such keys:
%
\begin{codeexample}[
    width=7cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\tikz \datavisualization
  [scientific axes,
   x axis={ticks={stack, many, major also at=
     {(pi) as [{tick text padding=2.5em}] $\pi$}}},
   visualize as smooth line]
  data [format=function] {
    var x : interval[0:(2*pi)];
    func y = sin(\value x r);
  };
\end{codeexample}


\subsubsection{Reference: Basic Strategies}
\label{section-dv-strategies}

\begin{key}{/tikz/data visualization/axis options/linear steps}
    This strategy places ticks at positions that are evenly spaced by the current value of |step|.

    In detail, the following happens: Let $a$ be the minimum value of the data values along the axis and let $b$ be the maximum. Let the current \emph{stepping} be $s$ (the stepping is set using the |step| option, see below) and let the current \emph{phasing} be $p$ (set using the |phase|) option. Then ticks are placed all positions $i\cdot s + p$ that lie in the interval $[a,b]$, where $i$ ranges over all integers.

    The tick positions computed in the way described above are \emph{major} step positions. In addition to these, if the key |minor steps between steps| is set to some number $n$, then $n$ many minor ticks are introduced between each two major ticks (and also before and after the last major tick, provided the values still lie in the interval $[a,b]$). Note that is $n$ is $1$, then one minor tick will be added in the middle between any two major ticks. Use a value of $9$ (not $10$) to partition the interval between two major ticks into ten equally sized minor intervals.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\begin{tikzpicture}
  \datavisualization
    [scientific axes={inner ticks, width=3cm},
     x axis={ticks={step=3, minor steps between steps=2}},
     y axis={ticks={step=.36}},
     visualize as scatter]
    data {
      x, y
      17, 30
      34, 32
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}

\label{section-dv-exponential-strategy}

\begin{key}{/tikz/data visualization/axis options/exponential steps}
    This strategy produces ticks at positions that are appropriate for logarithmic plots. It is automatically selected when you use the |logarithmic| option with an axis.

    In detail, the following happens: As for |linear steps| let numbers $a$, $b$, $s$, and $p$ be given. Then, major ticks are placed at all positions $10^{i\cdot s+p}$ that lie in the interval $[a,b]$ for $i \in \mathbb{Z}$.

    The minor steps are added in the same way as for |linear steps|. In particular, they interpolate \emph{linearly} between major steps.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\begin{tikzpicture}
  \datavisualization
    [scientific axes,
     x axis={logarithmic, length=2cm, ticks={step=1.5}},
     y axis={logarithmic, ticks={step=1, minor steps between steps=9}},
     visualize as scatter]
    data {
      x, y
      1, 10
      1000, 1000000
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}


\subsubsection{Advanced: Defining New Placement Strategies}

\begin{key}{/tikz/data visualization/axis options/tick placement strategy=\meta{macro}}
    This key can be used to install a so-called \emph{tick placement strategy}. Whenever |visualize ticks| is used to request some ticks to be visualized, it is checked whether some automatic ticks should be created. This is the case when the following key is set:
    %
    \begin{key}{/tikz/data visualization/compute step=\meta{code}}
        The \meta{code} should compute a suitable value for the stepping to be used by the \meta{macro} in the tick placement strategy.

        For instance, the |step| key sets |compute step| to |\def\tikz@lib@dv@step{#1}|. Thus, when you say |step=5|, then the desired stepping of |5| is communicated to the \meta{macro} via the macro |\tikz@lib@dv@step|.
    \end{key}

    Provided |compute step| is set to some nonempty value, upon visualization of ticks the \meta{macro} is executed. Typically, \meta{macro} will first call the \meta{code} stored in the key |compute step|. Then, it should implement some strategy then uses the value of the computed or desired stepping to create appropriate |at| commands. To be precise, it should set the keys |major|, |minor|, and/or |subminor| with some appropriate |at| values.

    Inside the call of \meta{macro}, the macro |\tikzdvaxis| will have been set to the name of the axis for which default ticks need to be computed. This allows you to access the minimum and the maximum value stored in the |scaling mapper| of that axis.
    %
\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}]
\def\silly{
  \tikzdatavisualizationset{major={at={
        2,3,5,7,11,13}}}
}
\begin{tikzpicture}
  \datavisualization [
    scientific axes, visualize as scatter,
    x axis={tick placement strategy=\silly}
    ]
    data {
      x, y
      0, 0
      15, 15
    };
\end{tikzpicture}
\end{codeexample}
    %
\end{key}


\subsection{Advanced: Creating New Axis Systems}

The |datavisualization| library comes with a number of predefined axis systems, like |scientific axes=clean|, but it is also possible and to define new axis systems. Doing so involves the following steps:
%
\begin{enumerate}
    \item Creating a number of axes.
    \item Configuring attributes of these axes like their length or default
        scaling.
    \item Creating visual representations of the axes.
    \item Creating visual representations of the ticks and grid lines.
\end{enumerate}

The first step uses |new ... axis| keys to create new axes, the last steps use |visualize ...| keys to create the visual representations of the axes.

Note that the axis system has no control over the actual attribute value ranges and neither over which ticks need to be drawn. The axis system can only provide good defaults and then specify \emph{how} the ticks or labels should be drawn and \emph{where} on the page -- but not at which values.

In the following, as a running example let us develop an axis system |our system| that does the following: For the $x$-axis is looks like a normal scientific axis system, but there are actually two $y$-axes: One at the left and one at the right, each using a different attribute, but both coexisting in the same picture.


\subsubsection{Creating the Axes}

A new axis system is created as a style key with the prefix |/tikz/data visualization|. Thus, we would write:
%
\begin{codeexample}[code only]
\tikzset{
  data visualization/our system/.style={
    ...
  }
}
\end{codeexample}

In our system we need three axis: The $x$-axis, the left axis and the right axis. Since all of these axes are Cartesian axes, we write the following:
%
\begin{codeexample}[code only]
\tikzset{
  data visualization/our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
  }
}
\end{codeexample}
%
As can be seen, we also configure things so that the $x$-axis will use the |x| attribute by default (users can later change this by saying |x axis={attribute=|\meta{some other attribute}|}|), but we do not configure the attributes of the |left axis| nor the |right axis|. We also make the left and right axis point upward (the |x axis| needs no configuration here since a Cartesian axis points right by default). The reason is the |left| would not be a particularly good attribute name and this way we ensure that users have to pick names themselves (hopefully good ones).

The next step is to define a standard scaling for the axes. Here, we can use the same as for |scientific axes|, so we would add the following keys to the definition of |our system|:
%
\begin{codeexample}[code only]
x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
\end{codeexample}

We now already have enough to try our system, although we will not yet see any axes or ticks, but we will see the correct scaling of the attributes. Let us first define a data group:
%
\begin{codeexample}[setup code]
\tikz \datavisualization data group {people and money} = {
    data [set=people 1] {
      time, people
      1900, 1000000000
      1920, 1500000000
      1930, 2000000000
      1980, 3000000000
    }
    data [set=people 2] {
      time, people
      1900, 2000000000
      1920, 2500000000
      1940, 4000000000
      2000, 5700000000
    }
    data [set=money 1] {
      time, money
      1910, 1.1
      1920, 2
      1930, 5
      1980, 2
    }
    data [set=money 2] {
      time, money
      1950, 3
      1960, 3
      1970, 4
      1990, 3.5
    }
  };
\end{codeexample}

\begin{codeexample}[setup code,hidden]
\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}
\end{codeexample}
%
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=4cm},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2},
    people 1={style={visualizer color=blue}},
    people 2={style={visualizer color=blue!50}},
    money 1={style={visualizer color=red}},
    money 2={style={visualizer color=red!50}}]
  data group {people and money};
\end{codeexample}


\subsubsection{Visualizing the Axes}
\label{section-dv-visualize-axis}

We must now show the axes themselves. For this we can use the |visualize axis| key:

\begin{key}{/tikz/data visualization/axis options/visualize axis=\meta{options}}
    This key is passed to an axis as an option. It causes a visual representation of the axis to be created during the data visualization. The \meta{options} are used to determine where the axis should be drawn and how long it should be. We can specify, for instance, that an axis should be drawn at the minimum value of another axis or where another axis has the value |0|.


    \medskip
    \textbf{The goto, high, and low Keys.}
    In our example, the |left axis| should be shown at the left hand side. This is the position where the |x axis| has its minimum value. To specify this, we would use the following code:
    %
\begin{codeexample}[code only]
left axis={ visualize axis={ x axis={ goto=min } }
\end{codeexample}
    %
    As can be seen, we can pass another axis as an \meta{option} to |visualize axis|, where we pass the following key to the axis in turn:
    %
    \begin{key}{/tikz/data visualization/axis options/goto=\meta{value}}
        The key can be passed to an axis. It will set the attribute monitored by the axis to the given \meta{value}, which is usually some number. However, \meta{value} may also be one of the following, which causes a special behavior:
        %
        \begin{itemize}
            \item |min|: The attribute is set to the minimal value that the attribute has attained along this axis.
            \item |max|: Like |min|.
            \item |padded min|: This will also set the \meta{attribute}
                monitored by the axis to the same value as |min|. Additionally, however, the subkey |/data point/|\meta{attribute}|/offset| is set to the current padding for the minimum, see the description of |padding min| later on. The effect of this is that the actual point ``meant'' by the attribute is offset by this padding along the attribute's axis.
            \item |padded max|: Like |padded min|.
        \end{itemize}
    \end{key}

    The |right axis| would be visualized the same way, only at |goto=max|. The
    $x$-axis actually needs to be visualized \emph{twice}: Once at the bottom
    and once at the top. Thus, we need to call |visualize axis| twice for this
    axis:
    %
\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}
\begin{codeexample}[
    preamble={\usetikzlibrary{datavisualization}},
    pre={\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}}]
\tikzset{
  data visualization/our system/.append style={
    left axis= {visualize axis={x axis=   {goto=min}}},
    right axis={visualize axis={x axis=   {goto=max}}},
    x axis=    {visualize axis={left axis={goto=min}},
                visualize axis={left axis={goto=max}}},
 }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=4cm},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}

    There is another key that is similar to |goto|, but has a slightly
    different semantics:
    %
    \begin{key}{/tikz/data visualization/axis options/goto pos=\meta{fraction}}
        The key works like |goto|, only the \meta{fraction} is not interpreted as a value but as a fraction of the way between the minimum and the maximum value for this axis.

        Suppose that for an axis the attribute range interval is $[500,1000]$ and the reasonable interval is $[1,3]$. Then for a \meta{fraction} of |0|, the mapping process would choose value $1$ from the reasonable interval, for a \meta{fraction} of |1| the position $3$ from the reasonable interval, and for a \meta{fraction} or |0.25| the position $1.5$ since it is one quarter at the distance from $1$ to $3$.

        Note that neither the attribute range interval nor the transformation function for the attribute are important for the |goto pos| option -- the \meta{fraction} is computed with respect to the reasonable interval. Also note that the values of the actual attribute corresponding to the fractional positions in the reasonable interval are not computed.
        %
\begin{codeexample}[
    preamble={\usetikzlibrary{datavisualization}},
    pre={\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}}]
\tikzset{
  data visualization/our system/.append style={
    x axis=    {visualize axis={left axis={goto pos=0.25}},
                visualize axis={left axis={goto pos=0.5}}},
 }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=4cm},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
    \end{key}

    By default, when an axis is visualized, it spans the set of all possible values for the monitored attribute, that is, from |min| to |max|. However, there are actually two keys that allow you to adjust this:
    %
    \begin{key}{/tikz/data visualization/low=\meta{value}}
        This is the attribute value where the axis visualization starts. The same special values as for |goto| are permissible (like |min| or |padded min|, but also |0| or |1|).
    \end{key}
    %
    \begin{key}{/tikz/data visualization/high=\meta{value}}
        Like |low|, only for where the axis ends.
    \end{key}

    By default, |low=min| and |high=max| are set for an axis visualization. Another sensible setting is |low=padded min| and |high=padded max|. The following key provides a shorthand for this:
    %
    \begin{key}{/tikz/data visualization/padded}
        Shorthand for |low=padded min, high=padded max|.
    \end{key}
    %
    As an example, consider the |scientific axes=clean|. Here, each axis is actually drawn three times: Once at the minimum, once at the maximum and then once more at the padded minimum.


    \medskip
    \textbf{The axis line.}
    When an axis is drawn, \tikzname\ does not simply draw a straight line from the |low| position to the |high| position. In reality, the data visualization system uses the two commands |\pgfpathdvmoveto| and |\pgfpathdvlineto| internally. These will replace the straight line by a curve in certain situations. For instance, in a polar coordinate system, if an axis should be drawn along an angle axis for a fixed radius, an arc will be used instead of a straight line.


    \medskip
    \textbf{Styling the axis.}
    As can be seen, we now get the axis we want (but without the ticks, visualizing them will be explained later). The axis is, however, simply a black line. We can \emph{style} the axis in a manner similar to styling ticks and grid lines, see Section~\ref{section-dv-style}. In detail, the following styles get executed:
    %
    \begin{enumerate}
        \item |axis layer|
        \item |every axis|
        \item |styling|
    \end{enumerate}
    %
    Additionally, even before |every axis| is executed, |low=min| and
    |high=max| are executed.

    \begin{stylekey}{/tikz/data visualization/axis layer (initially on background layer)}
        The layer on which the axis is drawn. See the description of |grid layer| on page~\pageref{section-dv-grid-layer} for details.
    \end{stylekey}

    \begin{stylekey}{/tikz/data visualization/every axis}
        Put styling of the axis here. It is usually a good idea to set this style to |style={black!50}|.
    \end{stylekey}

    Recall that the |styling| key is set using the |style| key, see
    Section~\ref{section-dv-style}.
    %
% TODOsp: codeexamples: What is this empty `\tikzset` good for?
\tikzset{
}
\begin{codeexample}[
    preamble={\usetikzlibrary{datavisualization}},
    pre={\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}}]
\tikzset{
  data visualization/our system/.append style={
    every axis/.style={style=black!50}, % make this the default
    left axis= {visualize axis={x axis=   {goto=min}, style=red!75}},
    right axis={visualize axis={x axis=   {goto=max}, style=blue!75}},
    x axis=    {visualize axis={left axis={goto=min}},
                visualize axis={left axis={goto=max}}},
 }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=4cm},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
\tikzset{
  data visualization/our system/.append style={
    every axis/.style={style=black!50}, % make this the default
    left axis= {visualize axis={x axis=   {goto=min}, style=red!75}},
    right axis={visualize axis={x axis=   {goto=max}, style=blue!75}},
    x axis=    {visualize axis={left axis={goto=min}},
                visualize axis={left axis={goto=max}}},
 }
}


    \medskip
    \textbf{Padding the Axis.}
    When an axis is visualized, it is often a good idea to make it ``a little bit longer'' or to ``remove it a bit from the border'', because the visualization of an axis should not interfere with the actual data. For this reason, a \emph{padding} can be specified for axes:

    \begin{key}{/tikz/data visualization/axis options/padding min=\meta{dimension}}
        This is the dimension that is used whenever |goto=padded min| is used. The \meta{dimension} is then put into the |offset| subkey of the attribute monitored by the axis. When a data point is transformed by a linear transformer and when this subkey is nonzero, this offset is added. (For an angle axis of a polar transformer, the \meta{dimension} is interpreted as an additional angle rather than as an additional distance). Note that \meta{dimension} should typically be negative since ``adding the \meta{dimension}'' will then make the axis longer (because it starts at a smaller value). The standard axis systems set the padding to some default and take its value into account:
        %
\begin{codeexample}[
    width=8cm,
    preamble={\usetikzlibrary{datavisualization.formats.functions}},
]
\begin{tikzpicture}
  \datavisualization [scientific axes=clean,
                      x axis={padding min=-1cm},
                      visualize as smooth line]
    data [format=function] {
      var x : interval [-3:5];
      func y = \value x * \value x;
    };
\end{tikzpicture}
\end{codeexample}

        Using padded and using the |padded| key, we can visualize our axis ``a little removed from the actual data'':
        %
\begin{codeexample}[
    preamble={\usetikzlibrary{datavisualization}},
    pre={\tikzdatavisualizationset{
  our system/.style={
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    x axis={attribute=x},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}}
  }
}%
\tikzset{
  data visualization/our system/.append style={
    every axis/.style={style=black!50}, % make this the default
    left axis= {visualize axis={x axis=   {goto=min}, style=red!75}},
    right axis={visualize axis={x axis=   {goto=max}, style=blue!75}},
    x axis=    {visualize axis={left axis={goto=min}},
                visualize axis={left axis={goto=max}}},
 }
}}]
\tikzset{
  data visualization/our system/.append style={
    all axes=  {padding=.5em},
    left axis= {visualize axis={x axis=   {goto=padded min}, padded}},
    right axis={visualize axis={x axis=   {goto=padded max}, padded}},
    x axis=    {visualize axis={left axis={goto=padded min}, padded},
                visualize axis={left axis={goto=padded max}, padded}},
 }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=3cm},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
    \end{key}

    \begin{key}{/tikz/data visualization/axis options/padding max=\meta{dimension}}
        Works like |padding min|, but \meta{dimension} should typically be
        positive.
    \end{key}

    \begin{key}{/tikz/data visualization/axis options/padding=\meta{dimension}}
        Sets both |padding min| to the negated value of \meta{dimension} and
        |padding max| to \meta{dimension}.
    \end{key}
\end{key}


\subsubsection{Visualizing Grid Lines}
\label{section-dv-visualize-gridlines}

As explained earlier, the |grid| key is used to specify at which positions grid lines should be drawn in principle. However, this key does not actually cause any grid lines to be drawn. Instead, the |visualize grid| key is used by the axis system to specify how grid lines are drawn.

\begin{key}{/tikz/data visualization/axis options/visualize grid=\meta{options}}
    This key is passed to an axis. It causes grid lines to be drawn at the positions specified by the |grid| key for this axis. The \meta{options} govern where and how the grid lines will be drawn.


    \medskip
    \textbf{The direction axis.}
    At first sight, one might expect that the grid lines for an axis should simply be drawn perpendicular to the axis between the minimum and maximum value of the axis. However, things are somewhat more difficult in reality:
    %
    \begin{enumerate}
        \item A grid line is supposed to indicate all positions where a certain attribute attains a fixed value. But, then, a grid line does not really need to be a grid \emph{line}. Consider for instance a three dimensional axis system. A ``grid line'' for the $x$-coordinate |3| would actually be a ``grid plane''.
        \item For a polar coordinate  system and a fixed radius, this set of positions at a certain radius is not a straight line, but an arc. For more complicated coordinate systems such as the one arising from three-dimensional spherical projections, a grid line may well be a fairly involved curve.
    \end{enumerate}
    %
    The |visualize grid| command addresses these complications as follows:
    %
    \begin{enumerate}
        \item A grid line is always a line, not a plane or a volume. This means that in the example of a three dimensional axis system and the $x$-attribute being |3|, one would have to choose whether the grid line should go ``along'' the $y$-axis or ``along'' the $z$-axis for this position. One can, however, call the |visualize grid| command twice, once for each direction, to cause grid lines to be shown for both directions.
        \item A grid line is created by moving to a start position and then doing a lineto to the target position. However, the ``moveto'' and ``lineto'' are done by calling special commands of the data visualization system. These special commands allow coordinate system to ``notice'' that the line is along an axis and will allow them to replace the straight line by an appropriate curve. The polar axes systems employ this strategy, for instance.
    \end{enumerate}

    By the above discussion, in order to create a grid line for attribute $a$ having value $v$, we need to specify an axis ``along'' which the line should be drawn. When there  are only two axes, this is usually ``the other axis''. This ``other axis'' is specified using the following key:
    %
    \begin{key}{/tikz/data visualization/direction axis=\meta{axis name}}
        You must pass this key as an \meta{option} each time you use |visualize axis|. When the grid line is drawn, the attribute $a$ is set to $v$ and the axis \meta{axis name}'s attribute is set once to the current value of |low| and once to |high|. Then a line is drawn between these two positions using |\pgfpathdvlineto|.
    \end{key}
    %
    The |low| and |high| keys are the same as the ones used in the |visualize axis| key.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
    xyz Cartesian cabinet,
    all axes={visualize axis={low=0, style=->}},
    x axis={visualize grid={direction axis=y axis}, grid=many},
    visualize as scatter]
  data {
    x, y, z
    0, 0, 1
    0, 1, 0
    2, 2, 2
  };
\end{codeexample}
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
    xyz Cartesian cabinet,
    all axes={visualize axis={low=0, style=->}, grid=many},
    x axis={visualize grid={direction axis=z axis}},
    z axis={visualize grid={direction axis=x axis},
            visualize grid={direction axis=y axis},},
    visualize as scatter]
  data {
    x, y, z
    0, 0, 1
    0, 1, 0
    2, 2, 2
  };
\end{codeexample}


    \medskip
    \textbf{Styling the grid lines.}
    When a grid line is draw, styles are applied as described in Section~\ref{section-dv-styling-grid-lines}.


    \medskip
    \textbf{The major, minor, and subminor grid lines.}
    The |grid| option allows you to specify for each kind of grid line (major, minor, or subminor) a set of different values for which these grid lines should be drawn. Correspondingly, it is also possible to configure for each kind of grid line how it should be drawn. For this, the |major|, |minor|, |subminor|, and also the |common| keys can be used inside the \meta{options} of |visualize grid|. While as option to |grid| these keys are used to specify |at| values, as options of |visualize grid| they are used to configure the different kinds of grid lines.

    Most of the time, no special configuration is necessary since all styling is best done by configuring keys like |every major grid|. You need to use a key like |major| only if you wish to configure for instance the |low| or |high| values of a |major| grid line differently from those of |minor| grid lines -- are rather unlikely setting -- or when the styling should deviate from the usual settings.
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikz \datavisualization [
    xy Cartesian,
    all axes={visualize axis={low=0, style=->},
              grid={some, minor steps between steps}},
    x axis=  {visualize grid={
                direction axis=y axis,
                minor={low=0.25, high=1.75, style=red!50}}},
    visualize as scatter]
  data {
    x, y
    0, 0
    3, 3
  };
\end{codeexample}
    %
\end{key}

Returning to the example of |our system| with the two axis systems, it is straight-forward to configure the grid lines of the $x$-axis: The direction axis is either of the other two axis (they point in the same direction and they have the same range). For the other two axes, we visualize one grid independently of the other, using different colors.
%
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikzset{
  data visualization/our system/.append style={
    x axis=    {visualize grid={direction axis=left axis}},
    left axis= {visualize grid={direction axis=x axis,
                                common={style=red!50}}},
    right axis={visualize grid={direction axis=x axis,
                                common={style=blue!50}}},
  }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=3cm, grid=many},
    left axis ={attribute=money, grid=some},
    right axis={attribute=people, grid=few},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}


\subsubsection{Visualizing the Ticks and Tick Labels}
\label{section-dv-visualize-ticks}

\begin{key}{/tikz/data visualization/axis options/visualize ticks=\meta{options}}
    Visualizing a tick involves (possibly) drawing a tick mark and adding (possibly) the tick node. The process is similar to |visualize grid|: Users use the |ticks| key to configure how many ticks they would like for an axis and at which positions. The axis system uses the |visualize ticks| key to specify where these ticks should actually be shown.

    Unlike grid lines, which are typically only visualized once for each combination of an axis and a direction axis, tick marks might be visualized at different places for the same axis. Consider for instance the |scientific axes|:
    %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes, all axes={length=3cm},
                          x axis={ticks={stack}},
                          visualize as smooth line]
  data [format=function] {
    var x : interval [0:2];
    func y = \value  x*\value x;
  };
\end{codeexample}
    %
    Have a look at the ticks on the $y$-axis: There are ticks at values |0|, |1|, |2|, |3|, and~|4|. These are visualized both at the left side (where the tick nodes are also shown) and additionally also at the right side, but only as small marks. Similarly, the ticks on the $x$-axis appear at the bottom, but also (in much simpler versions) at the top. Both for the $x$-axis and for the $y$-axis the |visualize ticks| key was called twice.


    \medskip
    \textbf{The tick marks.}
    Drawing a tick mark is quite similar to visualizing a grid line; indeed a tick mark can be thought of as a ``mini grid line'': Just like a grid line it ``points a long an axis''. However, a tick will always be a short straight line -- even when the coordinate system is actually twisted (experimentation has shown that ticks that follow the curvature of the coordinate system like grid lines are hard to recognize). For this reason, the |low| and |high| keys have a different meaning from the one used with the |visualize grid| key. In detail to configure the size and position of a tick mark for the value $v$ of attribute $a$, proceed as follows:
    %
    \begin{itemize}
        \item The |visualize ticks| key will have setup attribute $a$ to be
            equal to $v$.
        \item You should now use the |goto| or |goto pos| key together with all \emph{other} axes to configure at which position with respect to these other options the tick mark should be shown. For instance, suppose we want tick marks in |our system| for the $x$-axis at the bottom and at the top. This corresponds to once setting the |left axis| to its minimal value and once to its maximal value:
            %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikzset{
  data visualization/our system/.append style={
    x axis={visualize ticks={direction axis=left axis, left axis={goto=min}},
            visualize ticks={direction axis=left axis, left axis={goto=max}},
    }
  }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=3cm, ticks=many},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
            %
        \item In the above example, we may wish to shorten the ticks a bit at the bottom and at the top. For this, we use the |low| and |high| key:
            %
            \begin{key}{/tikz/data visualization/low=\meta{dimension}}
                When used with the |visualize ticks| option, the |low| key contains a dimension that specifies the extend of the tick going ``toward the minimum'' of the direction axis. More precisely, when a tick mark is visualized, a unit tangent vector at the current data point in the direction of the |direction axis| is computed and this vector is multiplied by \meta{dimension} to compute the start position of the tick line. The end position is given by this vector times the |high| value.

                Note that the \meta{dimension} should usually be negative for the |low| key and positive for the |high| key.

                For tick marks where a tick label node is shown, the \meta{dimension} is increased by the current values of keys like |tick text even low padding|, see Section~\ref{section-dv-stacking} for details.
            \end{key}
            %
            \begin{key}{/tikz/data visualization/high=\meta{dimension}}
                Like |low|.
            \end{key}
            %
            \begin{key}{/tikz/data visualization/tick length=\meta{dimension}} Shorthand for |low=-|\meta{dimension}|, high=|\meta{dimension}.
            \end{key}

            What we want to happen is that in the upper visualization of the ticks the |low| value is |0pt|, while in the lower one the |high| value is |0pt|:
            %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikzset{
  data visualization/our system/.append style={
    x axis={
      visualize ticks={direction axis=left axis,high=0pt,left axis={goto=min}},
      visualize ticks={direction axis=left axis,low=0pt,left axis={goto=max}},
    }
  }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=3cm, ticks=many},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
            %
    \end{itemize}
    %
    In order to style the tick mark, use the styling mechanism that is detailed in Section~\ref{section-dv-styling-ticks}.


    \medskip
    \textbf{The tick label node.}
    At certain tick positions, we may wish to add a node indicating the value of the attribute at the given position. The |visualize ticks| command has no influence over which text should be shown at a node -- the text is specified and typeset as explained in Section~\ref{section-dv-tick-labels}.

    Each time |visualize ticks|, for each tick position up to two tick label nodes will be created: One at the |low| position and one at the |high| position. The following keys are used to configure which of these cases happen:
    %
    \begin{key}{/tikz/data visualization/tick text at low=\opt{\meta{true or false}} (default true)}
        Pass this option to |visualize ticks| when you want tick label nodes to be placed at the |low| position of each tick mark.
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization}}]
\tikzset{
  data visualization/our system/.append style={
    x axis={
      visualize ticks={direction axis=left axis, left axis={goto=min},
                       high=0pt, tick text at low, stack},
      visualize ticks={direction axis=left axis, left axis={goto=max},
                       low=0pt, tick text at high, stack}
    }
  }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, length=3cm, ticks=some},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}
    \end{key}
    %
    \begin{key}{/tikz/data visualization/tick text at high=\opt{\meta{true or false}} (default true)}
        Like |tick text at low|.
    \end{key}

    \begin{key}{/tikz/data visualization/no tick text}
        Shorthand for |tick text at low=false, tick text at high=false|.
        %
\begin{codeexample}[preamble={\usetikzlibrary{datavisualization.formats.functions}}]
\tikz \datavisualization [scientific axes, all axes={length=3cm},
                          x axis={ticks={
                              major also at={6.5 as [no tick text]}}},
                          visualize as smooth line]
  data [format=function] {
    var x : interval [5:10];
    func y = \value x * \value x;
  };
\end{codeexample}
    \end{key}

    When a tick label node is to be placed at the low or the high position, the next step is to determine the exact position and the correct anchor of the node. This is done as follows:
    %
    \begin{itemize}
        \item In order to compute an appropriate |anchor|, the tick mark is considered: This is a short line pointing in a certain direction. For a tick label node at the |low| position, the |anchor| attribute is setup in such a way that the node label will be below the |low| position when the tick mark direction points up, it will be to the right when the direction points left, above when it points down, and so on also for diagonal directions. Similarly, for the |high| position, when the direction points up, the node will be placed above the tick mark and so on.

            This computation is done automatically.
        \item The tick label node is styled. The styles that are applied are described in Section~\ref{section-dv-styling-ticks}.
        \item A tick label node for the |low| position is usually anchored at this |low| position, but an additional padding will be added as described in Section~\ref{section-dv-stacking}.
    \end{itemize}
\end{key}


\subsubsection{Visualizing the Axis Labels}
\label{section-dv-visualize-label}

The |label| option can be used with an axis to specify a text should be shown next to the axis to indicates which attribute this axis refers to. Like |ticks| or |grid|, the |label| option does not actually draw the label, this is the job of the |visualize label| key, which is configured by the axis system.

\begin{key}{/tikz/data visualization/axis options/visualize label=\meta{options}}
    The \meta{options} should be used to configure a ``good place'' for the axis label. Usually, you will use the |goto| or the |goto pos| key.

    For the example of |our system|, we would like the label of the |x axis| to be placed below at the middle of the axis, so we use |goto pos=.5| to determine this position. Concerning the other axes, we want it to be placed at the minimum position of the |left axis| with a lot of padding.
    %
\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}]
\tikzdatavisualizationset{
  our system/.append style={
    x axis={visualize label={
        x axis={goto pos=.5},
        left axis={padding=1.5em, goto=padded min}}}
  }
}
\tikz \datavisualization [
    our system,
    x axis={attribute=time, ticks=some, label},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={
      people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}

    In the above example, the |padding| of |1.5em| was rather arbitrary and ``suboptimal''. It would be outright wrong if the labels on the |x axis| were larger or if they were missing. It would be better if the vertical position of the |x axis| label were always ``below'' all other options. For such cases a slightly strange approach is useful: You position the node using |node style={at=...}| where |at| is now the normal \tikzname\ option that is used to specify the position of a node. Inside the |...|, you specify that the horizontal position should be the bottom of up-to-now-constructed data visualization and the vertical position should be at the ``origin'', which is, however, the position computed by the |goto| keys for the axes:
    %
\begin{codeexample}[width=7cm,preamble={\usetikzlibrary{datavisualization}}]
\tikzdatavisualizationset{
  our system/.append style={
    x axis={visualize label={
      x axis={goto pos=.5},
      node style={
        at={(0,0 |- data visualization bounding box.south)},
        below
} } } } }
\tikz \datavisualization [
    our system,
    x axis={attribute=time, ticks=some, label=Year},
    left axis ={attribute=money},
    right axis={attribute=people},
    visualize as line/.list={
      people 1, people 2, money 1, money 2}]
  data group {people and money};
\end{codeexample}

    Two additional keys are useful for positioning axis labels:
    %
    \begin{key}{/tikz/data visualization/axis option/anchor at min}
        When passed to an axis, this key sets the |anchor| so that a node positioned at either the |min| or the |padded min| value of the axis will be placed ``nicely'' with respect to the axis. For instance, if the axis points upwards from the |min| value to the |max| value, the |anchor| would be set to |north| since this gives a label below the axis's start. Similarly, if the axis points right, the anchor would be set to |east|, and so on.
    \end{key}
    %
    \begin{key}{/tikz/data visualization/axis option/anchor at max}
        Like |anchor at min|.
    \end{key}
\end{key}


\subsubsection{The Complete Axis System}

Here is the code for the complete axis system developed above and an example of how it is used:
%
\begin{codeexample}[code only]
\tikzdatavisualizationset{ our system/.style={
  % The axes
  new Cartesian axis=x axis,     new Cartesian axis=left axis,         new Cartesian axis=right axis,
  % The directions of the axes
  all axes={padding=.5em},       left axis={unit vector={(0cm,1pt)}},  right axis={unit vector={(0cm,1pt)}},
  % The default attributes, other attributes must be configured
  x axis={attribute=x},
  % The lengths of the axes
  x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
  left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
  right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
  % The styling of the axes
  every axis/.style={style=black!50}, % make this the default
  % Visualizing the axes themselves
  left axis= {visualize axis={x axis=   {goto=padded min}, style=red!75, padded}},
  right axis={visualize axis={x axis=   {goto=padded max}, style=blue!75,padded}},
  x axis=    {visualize axis={left axis={goto=padded min}, padded},
              visualize axis={left axis={goto=padded max}, padded}},
  % Visualizing the grid, when requested
  x axis=    {visualize grid={direction axis=left axis}},
  left axis= {visualize grid={direction axis=x axis, common={style=red!50}}},
  right axis={visualize grid={direction axis=x axis, common={style=blue!50}}},
  % Visualizing the ticks, when requested
  left axis={visualize ticks={style={red!50!black}, direction axis=x axis,
                              x axis={goto=padded min}, high=0pt, tick text at low}},
  right axis={visualize ticks={style={blue!80!black}, direction axis=x axis,
                              x axis={goto=padded max}, low=0pt, tick text at high}},
  x axis={visualize ticks={direction axis=left axis, left axis={goto=padded min}, high=0pt,
                           tick text at low},
          visualize ticks={direction axis=left axis, left axis={goto=padded max}, low=0pt}},
  % By default, there are ticks on all axes
  all axes={ticks},
  % Visualizing the axis labels, when requested
  x axis={visualize label={x axis={goto pos=.5}, node style={
        at={(0,0 |- data visualization bounding box.south)}, below}}},
  left axis={visualize label={left axis={goto pos=.5}, node style={
        at={(0,0 -| data visualization bounding box.west)}, rotate=90, anchor=south, red!50!black}}},
  right axis={visualize label={right axis={goto pos=.5}, node style={
        at={(0,0 -| data visualization bounding box.east)}, rotate=-90, anchor=south,  blue!80!black}}},
}}
\end{codeexample}

\begin{codeexample}[
    preamble={\usetikzlibrary{datavisualization}},
    pre={\tikzdatavisualizationset{
  our system/.style={
    % The axes
    new Cartesian axis=x axis,
    new Cartesian axis=left axis,
    new Cartesian axis=right axis,
    % The default attributes, other attributes must be configured
    x axis={attribute=x},
    % The directions of the axes
    all axes={padding=.5em},
    left axis={unit vector={(0cm,1pt)}},
    right axis={unit vector={(0cm,1pt)}},
    % The lengths of the axes
    x axis    ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}},
    left axis ={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    right axis={length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}},
    % The styling of the axes
    every axis/.style={style=black!50}, % make this the default
    % Visualizing the axes themselves
    left axis= {visualize axis={x axis=   {goto=padded min}, style=red!75, padded}},
    right axis={visualize axis={x axis=   {goto=padded max}, style=blue!75,padded}},
    x axis=    {visualize axis={left axis={goto=padded min}, padded},
                visualize axis={left axis={goto=padded max}, padded}},
    % Visualizing the grid, when requested
    x axis=    {visualize grid={direction axis=left axis, padded}},
    left axis= {visualize grid={direction axis=x axis, padded, common={style=red!50}}},
    right axis={visualize grid={direction axis=x axis, padded, common={style=blue!50}}},
    % Visualizing the ticks, when requested
    left axis={
      visualize ticks={style={red!50!black}, direction axis=x axis, x axis={goto=padded min}, high=0pt, tick text at low}},
    right axis={
      visualize ticks={style={blue!80!black}, direction axis=x axis, x axis={goto=padded max}, low=0pt, tick text at high}},
    x axis={
      visualize ticks={direction axis=left axis, left axis={goto=padded min}, high=0pt, tick text at low},
      visualize ticks={direction axis=left axis, left axis={goto=padded max}, low=0pt}
    },
    % By default, there are ticks on all axes
    all axes={ticks},
    % Visualizing the axis labels, when requested
    x axis={visualize label={
      x axis={goto pos=.5}, node style={at={(0,0 |- data visualization bounding box.south)}, below}}},
    left axis={visualize label={
      left axis={goto pos=.5}, node style={
        at={(0,0 -| data visualization bounding box.west)}, rotate=90, anchor=south, red!50!black}}},
    right axis={visualize label={
      right axis={goto pos=.5}, node style={
        at={(0,0 -| data visualization bounding box.east)}, rotate=-90, anchor=south,  blue!80!black}}},
  }
}}]
\tikz \datavisualization [
  our system,
  x axis={attribute=time, label=Year,
    ticks={tick text padding=2pt,  style={/pgf/number format/set thousands separator=}}},
  left axis={attribute=money, label=Spending,
    padding min=0, include value=0, grid,
    ticks={tick prefix=\$, style={/pgf/number format/fixed,
        /pgf/number format/fixed zerofill, /pgf/number format/precision=2}}},
  right axis={attribute=people,
    label=Population,
    padding min=0, include value=0,
    ticks={style=/pgf/number format/fixed}},
  visualize as line/.list={
    people 1, people 2, money 1, money 2},
  people 1={style={visualizer color=blue}},
  people 2={style={visualizer color=blue!50}},
  money 1={style={visualizer color=red}},
  money 2={style={visualizer color=red!50}} ]
data group {people and money};
\end{codeexample}


\subsubsection{Using the New Axis System Key}

The axis system |our system| that we developed in the course of the previous section is not yet ``configurable''. The only configuration that was possible was to ``misuse'' the |width| and |height| keys of the |scientific axes|.

In order to make |our system| configurable so that we can say |our system=|\meta{options}, where \meta{options} are executed with the path prefix
%
\begin{codeexample}[code only]
/tikz/data visualization/our system
\end{codeexample}
%
we can use the following key:

\begin{key}{/tikz/data visualization/new axis system=\marg{axis system
      name}\marg{axis setup}\marg{default options}\\ \marg{application
      options}%
}
    The |new axis system| key takes four parameters. The first one, \meta{system name}, is the name of the to-be-created axis system, |our system| in our case. The |new axis system| will create the following new key:
    %
    \begin{key}{/tikz/data visualization/\meta{axis system name}=\opt{\meta{options}}}
        When the key \meta{axis system name} is used, the following keys will be executed in the following order:
        %
        \begin{enumerate}
            \item The \meta{axis setup} with the path prefix
                |/tikz/data visualization/|.
            \item The \meta{default options} with the same path prefix.
            \item The following style:
                %
                \begin{stylekey}{/tikz/data visualization/every \meta{axis system name}}
                    Even though this style has the path prefix |/tikz/data visualization| itself, the keys stored in this style will be executed with the path prefix |/tikz/data visualization/|\meta{axis system name}.
                \end{stylekey}
            \item The \meta{options} with the path prefix |/tikz/data visualization/|\meta{axis system name}.
            \item The \meta{application options} with the path prefix |/tikz/data visualization/|
        \end{enumerate}
    \end{key}

    Let us now have a look at what all of this means. First, the \meta{axis setup} will contain all options that setup the axis system in all ways that need not be configured. For instance, the \meta{axis setup} for the |scientific axes| will create an |x axis| and also a |y axis| (because these are always present), but will not setup the label visualization (because this can be configured in different ways). For |our system|, which cannot be configured at all, we would place all of our configuration in the \meta{axis setup}.

    The \meta{default options} can be used to pick default values that would usually be passed to the \meta{options} of the newly created axis system. For instance, for |scientific axis|, the \meta{default options} are set to |outer ticks,standard labels|, because these are the defaults.

    Finally, the \meta{application options} can be used to actually apply the configuration that has been chosen by the \meta{options}. The idea is that \meta{default options}, \meta{options}, and also |every| \meta{axis system name} all have a chance of changing, re-changing and re-setting all sorts of styles and keys. Then, with the last change ``winning'', the resulting setting of a style can be executed, which may then cause a label visualization to be installed.
\end{key}
